You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
你好,使用代码过程中遇到了两个问题,不知道是否有解决的办法。
问题1:爬取过程中遇到“http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2020/36/3605.html
requests fail, retry!”
或者“Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\hp\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:/Users/hp/Desktop/python/pythonProject3/main.py", line 83, in getData
countyList = selector.xpath('//tr[@Class="countytr"]')
AttributeError: 'NoneType' object has no attribute 'xpath'”
我认为这可能是由于我爬取的次数过多,才出现这种情况。经过一段时间之后,再跑程序,该问题就解决了。不知道有没有更好的解决方法。
问题2:有一些行政区划代码没有链接,爬取的结果中没有包括这些码值,如“350527000000-金门县”、“350501000000-市辖区”。
The text was updated successfully, but these errors were encountered:
你好,使用代码过程中遇到了两个问题,不知道是否有解决的办法。
问题1:爬取过程中遇到“http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2020/36/3605.html
requests fail, retry!”
或者“Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\hp\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:/Users/hp/Desktop/python/pythonProject3/main.py", line 83, in getData
countyList = selector.xpath('//tr[@Class="countytr"]')
AttributeError: 'NoneType' object has no attribute 'xpath'”
我认为这可能是由于我爬取的次数过多,才出现这种情况。经过一段时间之后,再跑程序,该问题就解决了。不知道有没有更好的解决方法。
问题2:有一些行政区划代码没有链接,爬取的结果中没有包括这些码值,如“350527000000-金门县”、“350501000000-市辖区”。
The text was updated successfully, but these errors were encountered: