Comments (4)
Hi eweca1992,
Thanks for pointing out this issue!
I tried to set "time_list = 'NAr'" in "def time_str2float", and got "ValueError: invalid literal for int() with base 10" (I would like to suggest you check the name of the error you have met, here is "ValueError").
Thus, I modified this function by adding "try" and "except" operations as below:
def time_str2float2(timestamp):
'''Convert a timestamp to a floating number.
Parameter:
timestamp <str> - The input timestamp formatted as 'hh:mm:ss.msec'.
Return:
time_num <float> - The number of the input timestamp formatted as 'ss.msec'.
'''
time_list = re.split('[:]', timestamp)
time_list = 'N/A\r'
try:
time_num = int(time_list[0]) * 3600 + int(time_list[1]) * 60 + float(time_list[2])
return time_num
except ValueError:
print('*****Error: Invalid format of timestamp')
return 0
You could replace "ValueError" in "except ValueError" with the name of error you have met.
I hope this could help you to fix your issue. :P
Regards,
He
from weibo-crawler.
Hi eweca1992,
Thanks for pointing out this issue!
I tried to set "time_list = 'NAr'" in "def time_str2float", and got "ValueError: invalid literal for int() with base 10" (I would like to suggest you check the name of the error you have met, here is "ValueError").
Thus, I modified this function by adding "try" and "except" operations as below:
def time_str2float2(timestamp): '''Convert a timestamp to a floating number. Parameter: timestamp <str> - The input timestamp formatted as 'hh:mm:ss.msec'. Return: time_num <float> - The number of the input timestamp formatted as 'ss.msec'. ''' time_list = re.split('[:]', timestamp) time_list = 'N/A\r' try: time_num = int(time_list[0]) * 3600 + int(time_list[1]) * 60 + float(time_list[2]) return time_num except ValueError: print('*****Error: Invalid format of timestamp') return 0
You could replace "ValueError" in "except ValueError" with the name of error you have met.
I hope this could help you to fix your issue. :P
Regards,
He
Thank you for your reply. I would try it when my computer is free.
By the way, is it possible to auto re-connect weibo after request error? It seems that a "try...except" can do the work.
from weibo-crawler.
Hi eweca1992,
Thanks for pointing out this issue!
I tried to set "time_list = 'NAr'" in "def time_str2float", and got "ValueError: invalid literal for int() with base 10" (I would like to suggest you check the name of the error you have met, here is "ValueError").
Thus, I modified this function by adding "try" and "except" operations as below:def time_str2float2(timestamp): '''Convert a timestamp to a floating number. Parameter: timestamp <str> - The input timestamp formatted as 'hh:mm:ss.msec'. Return: time_num <float> - The number of the input timestamp formatted as 'ss.msec'. ''' time_list = re.split('[:]', timestamp) time_list = 'N/A\r' try: time_num = int(time_list[0]) * 3600 + int(time_list[1]) * 60 + float(time_list[2]) return time_num except ValueError: print('*****Error: Invalid format of timestamp') return 0
You could replace "ValueError" in "except ValueError" with the name of error you have met.
I hope this could help you to fix your issue. :P
Regards,
HeThank you for your reply. I would try it when my computer is free.
By the way, is it possible to auto re-connect weibo after request error? It seems that a "try...except" can do the work.
Hi,
Yes! First of all, the code will try at most 3 times to crawl the data of one Weibo post (3 "try-except" code in "def crawl_***") if "urllib.request.urlretrieve" function failed to download the data. If the code still cannot crawl the data after 3 times attempts, the data will not be saved. (I have never met this problem so far.)
Second, if you get the error: "ConnectionError 104: ('Connection aborted.')" (the most common one which is caused by the restriction of Sina Weibo. It is different with the first problem), the code will stop! In this case, you could follow the information described in the 8-th procedure of User Settings of Usage in README and manually re-start the code to continue to crawl data. Currently, the crawler cannot automatically do this. I am sorry. XD
Regards,
He
from weibo-crawler.
Thank you for your patient reply.
from weibo-crawler.
Related Issues (12)
- Limitations
- KeyError: 'pic_video' HOT 1
- 抓取到live photo会报错 HOT 2
- Cannot find "getindex" on network -> XHR HOT 3
- 能否实现自动转发抽奖微博
- Limitation HOT 3
- Crawl transmitted Weibo posts.
- Unknown Bug HOT 1
- Crawl img in transferred text. HOT 1
- Limitation - Cannot crawl video from re-tweeted post HOT 2
- 该爬虫在爬取只有表情的微博时,会出现*****Error: Failed to extract text. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from weibo-crawler.