소스 검색

first crawler

chuwanghui 6 년 전
부모
커밋
262c921942
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      ApiCrawler/ApiCrawler/spiders/apispider.py

+ 3 - 0
ApiCrawler/ApiCrawler/spiders/apispider.py

@@ -57,6 +57,9 @@ class ApiSpider(scrapy.spiders.Spider):
         #获取类名为book的div中的内容
         _content=response.xpath("//div[@class='book']").xpath('string(.)')
         apiItem['content']=_content[0].extract() if _content else ""
+        #作者信息
+        _author=response.xpath("//pre[@class='authors']").xpath('string(.)')
+        apiItem['author']=_author[0].extract() if _author else ""
 
         yield apiItem