python
大家都叫我船长
这个作者很懒,什么都没留下…
展开
-
python实现推酷网站登录后,获取推荐内容
import requests from lxml import etree class Login(object): def __init__(self): self.headers = { 'Referer': 'https://www.tuicool.com/login', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 .原创 2020-05-23 16:00:16 · 227 阅读 · 0 评论 -
python爬取推酷页面标题,来源和时间代码
import re import requests from lxml import etree from bs4 import BeautifulSoup import csv def get_one_page(url): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 .原创 2020-05-19 20:07:12 · 388 阅读 · 0 评论 -
错误:NameError: name 'HTTPError' is not defined解决方式
第一种解决方式: from urllib2 import urlopen, HTTPError try: # ... except HTTPError: pass 第二种解决方式: import urllib2 try: # ... response = urllib2.urlopen(...) # ... except u...原创 2020-01-11 14:08:38 · 2940 阅读 · 0 评论