如何获取Instagram图片详细信息 [英] How to get Instagram image details
问题描述
我正在开发一个应用程序,以通过将硒与python一起使用来从Instagram获取图像详细信息.
I am working on an app to get images details from Instagram by using selenium with python.
driver.execute_script(SCROLL_TOP)
driver.execute_script(SCROLL_BOTTOM)
结果是,可以从driver.page_source
但是当我尝试获取有关图片的更多信息时(例如,喜欢的次数,发布日期).我需要访问
But when I trying to get more information about an image (e.g, number of likes, date of the image published). I need to access
<script type="text/javascript">window._sharedData = {...}</script>
上一个代码中的"..."是一个JSON块.它包含前12个媒体的详细信息.有没有办法在window._shareData JSON块中获取所有图像的详细信息?
The '...' in the previous code is a JSON block. It contains the first 12 media's details. Is there a way I get all image's details in the window._shareData JSON block?
感谢您的建议
推荐答案
Take a look at my answer which solves your problem but with php. Anyway, you can do the same with python:
-
通过url中的http加载json :(用任何公共用户名替换
nasa
).
从json中获取12个媒体详细信息:user->media->nodes
.
Get 12 media details from the json: user->media->nodes
.
从json中获取其他媒体信息:user->media->page_info
.有has_next_page
(布尔值)和end_cursor
(整数).用它来获取URL为https://www.instagram.com/nasa/?__a=1&max_id=[VALUE-FROM-end_cursor]
的下12种媒体.
Get the additional media info from the json: user->media->page_info
. There are has_next_page
(boolean) and end_cursor
(integer). Use it to get next 12 media with url https://www.instagram.com/nasa/?__a=1&max_id=[VALUE-FROM-end_cursor]
.
这篇关于如何获取Instagram图片详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!