0
私はscrapyとpythonの使い方を勉強しようとしていますが、私は専門家ではありません。 私はいつもこのページをクロールした後、空のファイルがあります:product of c-discountを、私は理由を理解していない...ここでScrap-crawled(200)and referer:none
が私のコードです:
import scrapy
from cdiscount_test.items import CdiscountTestItem
f = open('items.csv', 'w').close()
class CdiscountsellersspiderSpider(scrapy.Spider):
name = 'CDiscountSellersSpider'
allowed_domains = ['cdiscount.com']
start_urls = ['http://www.cdiscount.com/mpv-8732-SATENCO.html']
def parse(self, response):
items = CdiscountTestItem()
name = response.xpath('//div[@class="shtName"]/div[@class="shtOver"]/h1[@itemprop="name"]/text()').extract()
country = response.xpath('//div[@class="shtName"]/span[@class="shTopCExp"]/text()').extract()
items['name_seller'] = ''.join(name).strip()
items['country_seller'] = ''.join(country).strip()
pass
そして、私はCMDウィンドウで取得結果:
2017-06-20 18:01:50 [scrapy.core.engine] INFO: Spider opened
2017-06-20 18:01:50 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0
pages/min), scraped 0 items (at 0 items/min)
2017-06-20 18:01:50 [scrapy.extensions.telnet] DEBUG: Telnet console
listening on 127.0.0.1:6023
2017-06-20 18:01:51 [scrapy.core.engine] DEBUG: Crawled (200) <GET
http://www.cdiscount.com/robots.txt> (referer: None)
2017-06-20 18:01:51 [scrapy.core.engine] DEBUG: Crawled (200) <GET
http://www.cdiscount.com/mpv-8732-SATENCO.html> (referer: None)
2017-06-20 18:01:51 [scrapy.core.engine] INFO: Closing spider (finished)
私を助けてくれる人がいますか?
ありがとうございました!!!
ありがとう、私の悪い...ありがとうございました!私は歩留まりが役に立ったところで何か複雑なものを探していました... –
そしてあなたは're() 'を知っていますか?私は、そのようなものを見ただけで、テキストの一部を保存することができましたが、私はどの文字が() –