如何使用python3x循环抓取网站中多个页面的数据

时间:2017-11-19 13:54:29

标签: python-3.x loops web-scraping

我需要做一个循环并从页面获取json数据。页面URL的生成如下:

https: //*.*bounds=506,168,507,169
https: //*.*bounds=506,169,507,170
https: //*.*bounds=506,170,507,171
https: //*.*bounds=506,170,507,171
https: //*.*bounds=505,171,506,172
https: //*.*bounds=506,173,507,174

取决于坐标。

例如,

https: //*.*bounds=506,170,507,171           

       for Latitude:  50.6015314505
           longitude: 17.0410603428

https://*.*bounds=508,163,509,164

       for Latitude:  50.859299
           longitude: 16.3206665

我认为这个循环必须包括这样的东西:

https: //*.*bounds= {lat}, {lon}, {lat + 1}, {lon + 1}?

限制:

  • minLongitude = 140
  • maxLongitude = 242
  • minLatitude = 490
  • maxLatitude = 549

如何在Python 3中执行此操作?

1 个答案:

答案 0 :(得分:0)

解决方案:

for lat in range(490, 550):
    for lon in range(140,243):
        print("%d,%d,%d,%d" % (lat, lon, lat + 1, lon + 1))