Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';使用pythonawhere时,不要在网页上进行Selenium搜索_Python_Python 3.x_Selenium_Pythonanywhere - Fatal编程技术网

Can';使用pythonawhere时,不要在网页上进行Selenium搜索

Can';使用pythonawhere时,不要在网页上进行Selenium搜索,python,python-3.x,selenium,pythonanywhere,Python,Python 3.x,Selenium,Pythonanywhere,我试图找到一些关于使用Selenium的元素,我的代码在我的计算机上运行,但当我在PythonyWhere上运行它并试图找到至少一个body时,它返回“”。代码: from selenium import webdriver def code(): browser = webdriver.Firefox() browser.get('https://instagram.com') print(browser.find_element_by_tag_name('body'

我试图找到一些关于使用Selenium的元素,我的代码在我的计算机上运行,但当我在PythonyWhere上运行它并试图找到至少一个body时,它返回“”。代码:

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()

我试着用他们网站上的一些随机网站进行测试,结果成功了!但是Instagram也在那里。。。所以,我有点困惑。我犯了什么错?非常感谢您的帮助。

我们没有将顶级instagram域(instagram.com)列入白名单,只有子域(如api.instagram.com等)列入白名单,因此您无法使用selenium刮取instagram。但是,您可以使用API,因为这是从软件访问instagram的首选方式

'https://.instagram.com“
有点奇怪,是不是应该是
”https://instagram.com“
没有多余的点吗?@Gilestomas是的,没有多余的点,我拼错了。但这并不能解决问题。如果它在没有登录instagram的情况下运行,那里可能没有太多/任何文本。您是否尝试登录并检查了
BODY
?@JeffC我尝试过这样做,但找不到表单(用户名和密码字段),所以有人建议我尝试打印BODY以检查我的代码是否打开了网站如果打印browser.page\u source呢?