Home > other >  Scrapy how to perform multiple urls in start_urls
Scrapy how to perform multiple urls in start_urls

Time:10-23

Has climbed to a city hotel, if you want to climb several cities hotel how to implement the url of the data, analytical methods, is only the city is not the same as the url
 
The class HotelSpiderSpider (scrapy. Spiders) :
Name='hotel_spider'
Allowed_domains=[' hotels.ctrip.com ']
# entry URL
Start_urls=[
'https://hotels.ctrip.com/hotel/Haikou42.html', # haikou
# # 'url1, city 1
# # 'url2, city 2
# # 'url3', city 3
# # 'url4', city 4
# 'url5', # 5 city
# # 'url6 city 6
]

In the default data parsing a single city hotels during the parse method
Is how to cycle to obtain the data of multiple hotel, turn to the great god, just an introduction to Python

CodePudding user response:

This web page must have a choice city list or find it is the json data put it off to get all the url of the city

CodePudding user response:

reference 1st floor JMZL response:
web page must have a choice as city a list of web pages or find it is the json data catch it can get all the city's url

Has made urban url, the question now is how to cycle to run each url, how do you cycle start_urls run

CodePudding user response:

You have access to a single function of the city with circular calls, every time send a url into it
  • Related