Использование python 3.5.
Когда мой код ниже печатает bs.parse()
, он показывает шестнадцатеричное значение объекта вместо значения bs.parse
.
Что я делаю неправильноздесь?
class BrickSetSpider(scrapy.Spider):
name = "website_spider"
site_search_url = 'website.com'
website_base = 'http://www.websitenew.com/search?id=site:'
start_urls = [website_base + site_search_url]
def parse(self, response):
website_result_list = []
website_result_page = []
NEXT_PAGE_SELECTOR = 'a.sb_pagN ::attr(href)'
next_page = response.css(NEXT_PAGE_SELECTOR).extract_first()
if next_page:
yield scrapy.Request(
response.urljoin(next_page),
callback=self.parse,
headers={'referer':self.start_urls}
)
website_result_page.append(response.urljoin(next_page))
#create LIST into SET to remove duplicates then change SET back to LIST.
set(website_result_page)
list(website_result_page)
for brp in website_result_page:
return("printing brp: " + brp)
bs = BrickSetSpider()
print(bs.parse('200'))
возвращает: <generator object BrickSetSpider.parse at 0x7f6f609c8f10>