ttgy.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:picScrapy 作者: JunWangCode 项目源码 文件源码
def parse(self, response):
        parent_path = response.xpath('//section[@id="m-category"]')
        for i in range(1, 9):
            category_name = parent_path.xpath("./ul/li["+str(i)+"]/a/text()").extract()[0]
            all_urls = parent_path.xpath(".//div/div["+str(i)+"]/ul/li/a/@href").extract()
            for url in all_urls:
                class_id = re.search('\d+', url).group()
                next_url = "http://m.fruitday.com/ajax/prolist/index"
                yield FormRequest(next_url, formdata={"class_id": class_id, "curr_page": "0"},
                                  callback=self.parse_data,
                                  meta={"cat": category_name, "class_id": class_id, 'page': "0"})

    # ?????????
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号