Web scraping Can';t由于';隐藏的';评论

Web scraping Can';t由于';隐藏的';评论,web-scraping,python-requests,instagram,Web Scraping,Python Requests,Instagram,我遇到了一些问题。 我写了一个脚本,该脚本应该可以删除Instagram的评论。一切都很好,但是:这个脚本只抓取可见的评论(但是大多数评论被这个按钮隐藏(“用英语显示更多”),那么,我如何修改我的脚本来抓取所有评论呢 def get_comment_inst(后链接列表): 索引=0 comment_frame=pd.DataFrame(列['text','user','time', “节点文本”、“节点名称”、“节点时间”]) 对于帖子链接列表中的url帖子: params='{'+'“sho

我遇到了一些问题。 我写了一个脚本,该脚本应该可以删除Instagram的评论。一切都很好,但是:这个脚本只抓取可见的评论(但是大多数评论被这个按钮隐藏(“用英语显示更多”),那么,我如何修改我的脚本来抓取所有评论呢

def get_comment_inst(后链接列表):
索引=0
comment_frame=pd.DataFrame(列['text','user','time',
“节点文本”、“节点名称”、“节点时间”])
对于帖子链接列表中的url帖子:
params='{'+'“shortcode”:“{}”。格式(url_post[28:-1])+\
“子注释计数”:3,“获取注释计数”:40,“父注释计数”:24,“有线程注释”:“真”+“}”
url='1〕https://www.instagram.com/graphql/query/?query_hash=eaffee8f3c9c089c9904a5915a898814&variables=“+params
wera=requests.get(url=url).json()
对于wera中的i['data']['shortcode\u media']['edge\u media\u to\u parent\u comment']['edges']:
text=i['node']['text']
user=i['node']['owner']['username']
time_of_comment=time.ctime(int(i['node']['created_at']))
如果(i['node']['edge\u threaded\u comments']['edges']):
对于i['node']['edge\u threaded\u comments']['edges']中的j:
node_text=j['node']['text']
node_name=j['node']['owner']['username']
node_time=time.ctime(j['node']['created_at'])
comment\u frame.loc[index]=[文本、用户、时间\u注释,
节点\文本、节点\名称、节点\时间]
指数+=1
其他:
node_text=“”
node_name=“”
node_time=“”
comment\u frame.loc[index]=[文本、用户、时间\u注释,
节点\文本、节点\名称、节点\时间]
指数+=1
返回注释框

一个简单的方法是在“显示更多”上单击,为此,您应该使用无头浏览器,如Selenium。