如何将Selenium html页面传递给htmlXpathSelector

Dja*_*oPy 3 python selenium scrapy

我需要抓一个使用javascript的页面.这就是我使用Selenium的原因.问题是selenium无法获取所需的数据.

我想使用htmlXmlSelector来尝试获取数据.

如何将生成的html selenium传递给htmlXmlSelector?

Dja*_*oPy 6

这是我的解决方案:只需从selenium page_source创建htmlXpathSelector:

hxs = HtmlXPathSelector(text=sel.page_source)
Run Code Online (Sandbox Code Playgroud)