python - import strings into scrapy to use as crawl urls -


so question how tell scrapy crawl urls, set apart 1 string. example: https://www.youtube.com/watch?v=string got strings saved in txt file.

with open("plz_nummer.txt") f:     cityzip = f.read().rsplit('\n')   in xrange(0,len(cityzip)):      next_url = 'http://www.firmenfinden.de/?txtplz=' + cityzip[a] + '&txtbranche=&txtkunden='         pass 

i make loading of file zip codes part of start_requests method generator. in lines of:

import scrapy  class zipspider(scrapy.spider):     name = "zipcodes"     self.city_zip_list = []      def start_requests(self):         open("plz_nummer.txt") f:             self.city_zip_list = f.read().rsplit('\n')         city_zip in self.city_zip_list:             url = 'http://www.firmenfinden.de/?txtplz={}&txtbranche=&txtkunden='.format(city_zip)             yield scrapy.request(url=url, callback=self.parse)        def parse(self, response):         # else need         # in here         pass  

this should give starting point. read article: https://doc.scrapy.org/en/1.1/intro/tutorial.html


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -