python - 问题 Scaping Instagram Hashtag 帖子使用具有特殊字符的主题标签计数
问题描述
所以我可以用下面的代码刮掉 instagram hashtag 帖子的数量。
from selenium import webdriver
driver = webdriver.Firefox()
ig_link = 'https://www.instagram.com/explore/tags/100x35/'
driver.get(ig_link)
# Scrape Posts Count
posts_count = driver.find_element_by_xpath('//*[@id="react-root"]/section/main/header/div[2]/div[1]/div[2]/span/span').text
print(posts_count)
driver.close()
我遇到的问题是当哈希标签中有一个标志时,例如:
https://www.instagram.com/explore/tags/100x35/ _
from selenium import webdriver
driver = webdriver.Chrome()
ig_link = 'https://www.instagram.com/explore/tags/100x35/'
driver.get(ig_link)
# Scrape Posts Count
posts_count = driver.find_element_by_xpath('//*[@id="react-root"]/section/main/header/div[2]/div[1]/div[2]/span/span').text
print(posts_count)
driver.close()
我收到以下错误:
消息:没有这样的元素:无法找到元素:{"method":"xpath","selector":"// [@id="react-root"]/section/main/header/div[2]/div [1]/div[2]/span/span"}*
解决方案
推荐阅读
- android - 如何使底部导航栏通过 onSelected 更改页面?
- keras - keras 模型无法泛化
- database - 如何在laravel中将用户帖子保存在数据库中?
- apache-spark - 运行pyspark时没有这样的文件或目录错误
- c - 我正在尝试从文件中获取令牌并制作链接列表。但我失败了
- java - 在 jboss 中部署应用程序失败
- java - Android WebView 自动 Facebook 登录
- chatbot - 如何导入 Amazon Lex 意图并直接在 Botium convo 中使用它进行测试
- python - Python,在不同对象上调用方法给出相同的结果
- angular - 如何将排序添加到 mat-list 中?