我以前使用过的Instagram API的标签,位置等访问公众形象我创建了一个新的应用程序和检索的access_token
,但这些公共媒体的搜索不再返回任何数据。然而,他们返回200个状态。
在文档中,它说:“应用程序不接受”,为的public_content
范围,这是需要这些搜索。所以,看来,Instagram的API已被弃用。
这使得零意义,我(这就是为什么我在这里发帖),因为这些类型的搜索是在如此多的应用程序和服务的核心。我也受了这些请求仍然会返回200个回应混淆。
如果还有其他的方法来访问Instagram上公开的内容,比如使用Facebook的API我不知道。 Instagram的是否要完全防止开发人员访问公共的照片?还是这只是港口的Instagram的API功能,另一个API,如Facebook?
如果您无法使用API,您可以尝试取消HTML。
你可以得到的HTML通过链接https://www.instagram.com/explore/tags/[TAG]/需要的标签
例如
curl https://www.instagram.com/explore/tags/telegram/
然后,你必须找到刺痛至极从“<脚本类型=”文/ JavaScript的“> window._sharedData =”将会有JSON至极容易与任何流行languges解析开始。
从这个数据就可以得到职位的“简码”的名单。如“BfLErJ_hzak”
接下来,你可以得到通过链接https://www.instagram.com/p/[SHORTCODE]/?__a=1细节后
例如。
curl https://www.instagram.com/p/BfLErJ_hzak/?__a=1
它返回JSON数据。查看范例
{"graphql":{"shortcode_media":{"__typename":"GraphImage","id":"1714484640997652132","shortcode":"BfLErJ_hzak","dimensions":{"height":1080,"width":1080},"gating_info":null,"media_preview":"ACoqamHCl0YsgAyQeMc//qp8DFiXPUmrTTbarwgmUlfu8HHHGaHqES0yqT6ZH61Pa9vp/SlQIi7Rg4/X/P6Utuc84K4B4NG2gbkyj7v5/pQZcEinL1HsP8KhKE8+tMRkzHiqQcJzz/jVi4gOMpwfaqRmLrsfr09zTA3YYzjcR+A5/wA/hVvB2lhxxkf4H61BZy70GRgjj644zVxOmDUgCtnnvipQABiqhyhyPX9Kk88e1MCo6dR3rKeLKhx+PtW0/QfQVmwnlx7mmI0IYR5akcHAqfdtOTTLf/Vr9KbLUjJnCnv15qgUWi2JKHPPOP50/NNAf//Z","display_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/d44e27e253f499ab84bd5944c8a93313/5B044F81/t51.2885-15/e35/27581038_2488346268057255_6612776414812831744_n.jpg","display_resources":[{"src":"https://instagram.fhel3-1.fna.fbcdn.net/vp/0e2d4f8e3b780cc4fba827e2afbcd7bd/5B180DAB/t51.2885-15/s640x640/sh0.08/e35/27581038_2488346268057255_6612776414812831744_n.jpg","config_width":640,"config_height":640},{"src":"https://instagram.fhel3-1.fna.fbcdn.net/vp/2d7cba2b057809aa589ab589baed3aff/5B087C45/t51.2885-15/s750x750/sh0.08/e35/27581038_2488346268057255_6612776414812831744_n.jpg","config_width":750,"config_height":750},{"src":"https://instagram.fhel3-1.fna.fbcdn.net/vp/d44e27e253f499ab84bd5944c8a93313/5B044F81/t51.2885-15/e35/27581038_2488346268057255_6612776414812831744_n.jpg","config_width":1080,"config_height":1080}],"is_video":false,"should_log_client_event":false,"tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjpmYWxzZSwidXVpZCI6IjdiZjJhOGI4MTc5YzRmMTViYWZmOGViYjg4N2RkOWZhMTcxNDQ4NDY0MDk5NzY1MjEzMiJ9LCJzaWduYXR1cmUiOiIifQ==","edge_media_to_tagged_user":{"edges":[]},"edge_media_to_caption":{"edges":[{"node":{"text":"Cuando se te pegan las mantas \ud83d\ude48\ud83d\ude48\ud83d\ude48\n.\n10,90\u20ac\n.\nhttp://s.click.aliexpress.com/e/EaEYFaE\n\nFACEBOOK.COM/ROPATEANDO\nBLOG.ROPATEANDO.COM\n.\n#mantabebe#ropateando #elarmarioderopateando #telegram #pic #picoftheday #outfit #outfitoftheday #outfitpost #ropa #instame #instalike #instalove #instalook #fashion #moda #instablogger #ootd #love #instagood #me #cute #like #influencer #beautiful #style #streetstyle"}}]},"caption_is_edited":true,"edge_media_to_comment":{"count":2,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[{"node":{"id":"17850908371233214","text":"Link","created_at":1518602595,"owner":{"id":"55206905","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/0f2d694caef7809255bd21e18579ebf3/5B2176B2/t51.2885-19/s150x150/22802830_358422461266066_4296876623711436800_n.jpg","username":"lorenacuaja"}}},{"node":{"id":"17924024554016118","text":"Enviado","created_at":1518602616,"owner":{"id":"2096327952","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/b142448b7225a12c25a81c4e4f84a577/5B0BFE21/t51.2885-19/s150x150/11930847_519140961600089_515209800_a.jpg","username":"ropateando"}}}]},"comments_disabled":false,"taken_at_timestamp":1518602517,"edge_media_preview_like":{"count":19,"edges":[{"node":{"id":"330280392","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/ff423c2bc927ec317701338712461b28/5B246257/t51.2885-19/s150x150/26071831_1616366641789125_3093631880650555392_n.jpg","username":"vlimamart"}},{"node":{"id":"5979047553","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/f4d1635630b571fb16b2b1f1cf99fd8e/5B039B10/t51.2885-19/s150x150/21227380_116088969094159_5157150429842243584_a.jpg","username":"dochylos"}},{"node":{"id":"226729325","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/8f76c54bb62f45ec33fe5e8b0fa2b733/5B234418/t51.2885-19/11428696_136540733352298_2103764682_a.jpg","username":"elsagcallejo"}},{"node":{"id":"2958399052","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/2ca058e070ce56861ae48fbf2c8ea931/5B1D2C9B/t51.2885-19/s150x150/19429360_320564085053737_4974100564364230656_a.jpg","username":"suraj_sk2"}},{"node":{"id":"1375472655","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/a3fd8350cb45401d0ab50aad95ef427f/5B111BD7/t51.2885-19/s150x150/26151195_2090241727875639_7471255521614364672_n.jpg","username":"alandashenka"}},{"node":{"id":"265784569","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/4b062db4cbf5bb2a50fbbffe2d6109b9/5B253FE0/t51.2885-19/s150x150/25017909_2061467437421348_4184874695654375424_n.jpg","username":"themayorsstatement"}},{"node":{"id":"6883303908","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/b4577832af28080a9607edcb758799cc/5B1A8203/t51.2885-19/s150x150/25037105_1997130850508677_1213534002938380288_n.jpg","username":"real247fitness"}},{"node":{"id":"1476593644","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/69d2a696339d3e64a6d6449cd36d10b9/5B151E06/t51.2885-19/s150x150/12139598_1056916654326731_785215976_a.jpg","username":"bbstylemiami"}},{"node":{"id":"5373895103","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/e4d101a7b7823862ff5ea09b9ca64db0/5B1C6515/t51.2885-19/s150x150/18443920_1839735143016586_6944955834094845952_a.jpg","username":"iambrokool"}},{"node":{"id":"345451524","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/0b4a2bceb2eaa1efd841874df94367e0/5B0B0207/t51.2885-19/11821658_877787485604500_693329869_a.jpg","username":"pleasefashionofficial"}}]},"edge_media_to_sponsor_user":{"edges":[]},"location":null,"viewer_has_liked":false,"viewer_has_saved":false,"viewer_has_saved_to_collection":false,"owner":{"id":"2096327952","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/b142448b7225a12c25a81c4e4f84a577/5B0BFE21/t51.2885-19/s150x150/11930847_519140961600089_515209800_a.jpg","username":"ropateando","blocked_by_viewer":false,"followed_by_viewer":false,"full_name":"RopaTeando","has_blocked_viewer":false,"is_private":false,"is_unpublished":false,"is_verified":false,"requested_by_viewer":false},"is_ad":false,"edge_web_media_to_related_media":{"edges":[]}}}}a
正如你看到它包含图片,标题,用户的信息,用户的大关,评论...等许多。
根据您的问题,我想看看InstaPy。它有一个简单的API,它使用Selenium,对于浏览器自动化框架,这样你就可以避开API的限制。
安装InstaPy:
$ git clone https://github.com/timgrossmann/InstaPy.git
$ cd InstaPy
$ pip install .
# or
$ python setup.py install
创建一个脚本:
# scraper.py
from instapy import InstaPy
insta_username = ''
insta_password = ''
# if you want to run this script on a server,
# simply add nogui=True to the InstaPy() constructor
session = InstaPy(username=insta_username, password=insta_password)
session.login()
# set up all the settings
session.set_upper_follower_count(limit=2500)
session.set_do_comment(True, percentage=10)
session.set_comments(['aMEIzing!', 'So much fun!!', 'Nicey!'])
session.set_dont_include(['friend1', 'friend2', 'friend3'])
session.set_dont_like(['pizza', 'girl'])
# do the actual liking
session.like_by_tags(['natgeo', 'world'], amount=100)
# end the bot session
session.end()
运行该脚本:
$ python scraper.py
媒体:
如果你觉得不舒服使用Python,看看Puppeteer。
操纵木偶是节点库,提供了一个高层次的API来控制在DevTools协议无头铬或铬。它也可以被配置为使用全(非无头)铬或铬。
安装木偶:
npm i --save puppeteer
创建一个脚本:
// scraper.js
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://instagram.com');
// Take a screen shot
await page.screenshot({path: 'example.png'});
await browser.close();
})();
运行该脚本:
$ node scraper.js
如果你想登录,按照这个guide。