我试图从一个网页中提取信息,它要求我从下拉列表中进行选择,并根据选择一个表格出现各种信息。我在页面上有一个表单/列表的选择值列表,我想遍历并提取表信息。你知道吗
网页:https://www.mcafee.com/enterprise/en-us/support/product-eol.html
import scrapy
from scrapy.spiders import Spider
product_names = ['Host Intrusion Prevention','McAfee Agent','Active Response','Database Security']
class McAfee_Spider(scrapy.Spider):
name = 'McAfee'
allowed_domains = 'mcafee.com'
start_urls = 'https://www.mcafee.com/enterprise/en-us/support/product-eol.html'
for product in product_names:
def parse(self, response):
scrapy.FormRequest.from_response(
response,
formxpath="//form[@id='selectProductArea']",
formdata={
"SelectProductArea" : product },
clickdata = { "type": "select" },
)
def parse_table(self, response):
product = response.xpath("//table[@class="general eoldynamicContent"]//tbody//tr//td[1]").extract()
version = response.xpath("//table[@class="general eoldynamicContent"]//tbody//tr//td[2]").extract()
eos_notif = response.xpath("//table[@class="general eoldynamicContent"]//tbody//tr//td[3]").extract()
eol_date = response.xpath("//table[@class="general eoldynamicContent"]//tbody//tr//td[4]").extract()
我被困在如何形成提取XPath。我研究过的例子都有我可以访问的类,但是这个没有。此外,此网站要求我在表格出现之前从窗体/列表中单击,我使用的是“FORMCREQUEST.from\响应“但是我不确定我是否设置了正确的方法。你知道吗
我要提取的信息是产品名称、版本型号、支持结束通知和生命周期结束/支持结束信息。我想先将结果存储在数据框中,因为我需要连接其他来源的信息,然后导出到excel/csv。你知道吗
来自https://www.mcafee.com/enterprise/en-us/support/product-eol.html的“主机入侵防护”列表中第一个产品的预期结果
import pandas as pd
results = {'product':['McAfee Host Intrusion Prevention', 'McAfee Host Prevention for Linux'],
'version':['8.0','8.0 Patch 6'],
'eos_notif':['',''],
'eol_date':['','']}
pd.DataFrame(results)
你找错地方了。在您选择列表中的任何内容后,上述网站不会发送任何
FormRequest
。相反,它从https://www.mcafee.com/enterprise/admin/support/eol.xml
加载所有内容,只显示一段数据:相关问题 更多 >
编程相关推荐