【发布时间】:2021-11-08 03:14:51
【问题描述】:
我需要进行一些网页抓取,并且我正在使用 requests_html.HTMLSession 中的渲染方法,因为该页面使用 JavaScript。当我在我的电脑上运行脚本时,它运行良好,但我需要能够在天蓝色的虚拟机中运行它,它不起作用,因为它永远不会结束并抛出这个“从浏览器引发的异常”。你能帮帮我吗?
感兴趣的代码:
from requests_html import HTMLSession
...
def get_page_content(link):
s = HTMLSession()
response = s.get(link)
response.html.render(timeout=30, reload=False) #Here is where it fails.
s.close()
return response.text
谢谢
【问题讨论】:
-
您在本地 PC 和用于渲染脚本的 azure VM 中使用的浏览器是否相同?
标签: python azure web-scraping azure-virtual-machine