Web Scraper无法转到正确的页面

时间:2018-07-01 20:57:34

标签: python beautifulsoup scrapy

所以我一直尝试去http://ofcc.ohio.gov/Opportunities2#lt-126679-construction-bids来获取出价列表。但是,总是从主页http://ofcc.ohio.gov/Opportunities2读取数据。我已经尝试过用美丽的汤和Scrapy来解决这个问题,但没有任何效果。有什么建议吗?当我卷曲第一个URL时,它还会加载主页数据。 代码:

    import scrapy

class QuotesSpider(scrapy.Spider):
name = "quotes"

def start_requests(self):
    urls = [
        'http://ofcc.ohio.gov/Opportunities2#lt-126679-construction-bids',
    ]
    for url in urls:
        yield scrapy.Request(url=url, callback=self.parse)

def parse(self, response):
    page = response.url.split("/")[-2]
    filename = 'construction%s.html' % page
    with open(filename, 'wb') as f:
        f.write(response.body)
    self.log('Saved file %s' % filename)

1 个答案:

答案 0 :(得分:1)

只需点击http://ofcc.ohio.gov/Opportunities2#lt-126679-construction-bids,我就被困在等待出价加载...这是网站问题吗?

您收到任何错误消息吗?您的问题不是很详细