[英]Can't make Selenium search on a web page when using PythonAnywhere
I'm trying to find some elements on https://instagram.com using Selenium and my code works on my computer, but when I run it on PythonAnywhere and try to find at least body it returns " ". 我试图找到一些元素https://instagram.com使用Selenium和我的代码工作在我的电脑上,但是当我在PythonAnywhere运行它,并试图找到至少身体返回“”。 Code: 码:
from selenium import webdriver
def code():
browser = webdriver.Firefox()
browser.get('https://instagram.com')
print(browser.find_element_by_tag_name('body').text)
def main():
code()
if __name__ == '__main__':
main()
I tried to test it with some random web-sites from their Whitelist and it Worked! 我尝试使用其白名单中的一些随机网站对其进行测试,并且效果良好! But Instagram is also there... So, I am a little bit confused. 但是Instagram也在那里...所以,我有点困惑。 What's my mistake? 我怎么了 Any help is appreciated. 任何帮助表示赞赏。
We have not whitelisted the top-level instagram domain (instagram.com) only the subdomains (like api.instagram.com etc.) so you cannot scrape instagram using selenium. 我们没有将顶级instagram域(instagram.com)仅列入子域(如api.instagram.com等)的白名单,因此您无法使用硒抓取instagram。 You can, however, use the API since that is the preferred way of accessing instagram from software. 但是,您可以使用API,因为这是从软件访问instagram的首选方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.