如果使用 python 请求响应为 404,我该如何跳过?
How do I skip if the response is 404 using python requests?
for user in comments['comment_id']:
try:
get_profile(user)
except urllib.error.HTTPError:
continue
我遇到过这样的错误,我不知道如何解决这个问题
<ipython-input-38-c9a67ae2e3f1> in <module>()
2 for user in comments['comment_id']:
3 try:
----> 4 get_profile(user)
5 except urllib.error.HTTPError:
6 continue
/usr/local/lib/python3.7/dist-packages/requests/models.py in raise_for_status(self)
939
940 if http_error_msg:
--> 941 raise HTTPError(http_error_msg, response=self)
942
943 def close(self):
HTTPError: 404 Client Error: Not Found for url: https://m.facebook.com/344608967148594/about/
for user in comments['comment_id']:
try:
get_profile(user)
except:
continue
for user in comments['comment_id']:
try:
get_profile(user)
except urllib.error.HTTPError:
continue
我遇到过这样的错误,我不知道如何解决这个问题
<ipython-input-38-c9a67ae2e3f1> in <module>()
2 for user in comments['comment_id']:
3 try:
----> 4 get_profile(user)
5 except urllib.error.HTTPError:
6 continue
/usr/local/lib/python3.7/dist-packages/requests/models.py in raise_for_status(self)
939
940 if http_error_msg:
--> 941 raise HTTPError(http_error_msg, response=self)
942
943 def close(self):
HTTPError: 404 Client Error: Not Found for url: https://m.facebook.com/344608967148594/about/
for user in comments['comment_id']:
try:
get_profile(user)
except:
continue