2014-04-04 5 views
0

나는 Scrapy를 사용하여 특정 웹 사이트를 크롤링 할 크롤러를 만들었습니다. 크롤러는 URL이 지정된 정규식과 일치하면 url이 다른 정의 된 정규식과 일치하면 콜백 함수를 호출합니다. 크롤러를 만드는 주요 목적은 링크 내부의 콘텐츠가 아닌 웹 사이트 내에서 필요한 모든 링크를 추출하는 것이 었습니다. 누구든지 모든 크롤링 링크 목록을 인쇄하는 방법을 알려줄 수 있습니까? 코드는 다음과 같습니다크롤링 된 URL 검색

print title 

코드가 완벽하게 잘 작동

name = "xyz" 
allowed_domains = ["xyz.com"] 
start_urls = ["http://www.xyz.com/Vacanciess"] 
rules = (Rule(SgmlLinkExtractor(allow=[regex2]),callback='parse_item'),Rule(SgmlLinkExtractor(allow=[regex1]), follow=True),) 



def parse_item(self, response): 
#sel = Selector(response) 

#title = sel.xpath("//h1[@class='no-bd']/text()").extract() 
#print title 
print response 

. 내가 t은 실제 응답을 인쇄하려고하면 위의 코드와 같이, 그것은 저를 반환

[xyz] DEBUG: Crawled (200)<GET http://www.xyz.com/urlmatchingregex2> (referer: http://www.xyz.com/urlmatchingregex1) 
<200 http://www.xyz.com/urlmatchingregex2> 

사람이 실제 URL을 검색하는 저를 도와주세요.

답변

1

response.urlparse_item 방법으로 인쇄하여 크롤링 된 URL을 인쇄 할 수 있습니다. 문서는 here입니다.

+0

고마워, 내가 정확히 무엇을 찾고 있었는지 :) –

관련 문제