抓取的表格爬行,网站具有异常的html代码。

时间:2018-10-18 01:18:51

标签: python html scrapy web-crawler

第一篇文章。我感谢任何指导,迫不及待地回馈社区。

我正在尝试使用scrapy做一个爬虫,以从该表中收集数据。

http://www.wikicfp.com/cfp/call?conference=machine%20learning

特别是会议名称,地点和日期。但是表tr和td没有类,并且该表位于另一个表中。

无论我如何编辑编解码器,它都会不断为我提供整个页面。

import scrapy


class CfpspiderSpider(scrapy.Spider):
name = 'cfpspider'
allowed_domains = ['http://www.wikicfp.com']
start_urls = ['http://www.wikicfp.com/cfp/call?conference=machine%20learning']

def parse(self, response):
    div = response.css("div.contsec")

    for table in div:
        print(table.css("table")[3].css.extract_first())

稍后,我将继续将其移至下一页并输出csv或json,但现在我正在尝试获取此表的一部分。我已经在scrapy shell中测试了一些命令,但是缺乏我的知识。 谢谢

1 个答案:

答案 0 :(得分:0)

按照源代码的外观,页面的结构如下:

Execute shell

编辑:尝试

div class="contsec"
| center
| | form
| | | table
| | | | tr
| | | | tr
| | | | tr
| | | | | td
| | | | | | table id="the droids you are looking for"
| | | | tr
相关问题