会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133940个问题

代码:

mport requests
from bs4 import BeautifulSoup
from fake_useragent import UserAgent
from time import sleep
def get_url(url):
    proxies={"http":"http://61.135.155.82:443"}
    headers={"User-Agent":UserAgent().random}
    # sleep(2)
    resp=requests.get(url,headers=headers,proxies=proxies,timeout=5)
    resp.encoding="utf-8"
    if resp.status_code==200:
        return resp.text
    else:
        return None
def parse_list(html):
    soup=BeautifulSoup(html,'lxml')
    movie_list=["http://maoyan.com{}".format(a.get('href')) for a in soup.select('dl[class="movie-list"] dd>div[class="movie-item film-channel"]>a')]
    return movie_list
def parse_index(html):
    soup=BeautifulSoup(html,'lxml')
    title=soup.select('div[class="movie-brief-container"]>h1')
    # type=soup.select('div[class="movie-brief-container"]>ul>li>a')
    print(title[0].text)
    # print(type[0].text)
def main():
    url="https://maoyan.com/films?showType=3&offset=0"
    html=get_url(url)
    movie_list=parse_list(html)
    for url in movie_list:
        # print(url)
        html=get_url(url)
        parse_index(html)
if __name__=="__main__":
    main()

运行结果:

屏幕截图 2021-03-11 073945.png

老师请问一下,为什么我的程序timeout错误,网上说要设置一个timeout时间,我设置了一个timeout=5可是还是报错,请问这是什么原因?麻烦老师帮我看一下

Python 全系列/第十六阶段:Python 爬虫开发/爬虫反反爬- 24166楼
Python 全系列/第十二阶段:Python_Django3框架/Django初级 24167楼
JAVA 全系列/第六阶段:项目管理与SSM框架/Mybatis 24168楼
Python 全系列/第十二阶段:Python_Django3框架/Django初级 24169楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程技术(旧) 24170楼
WEB前端全系列/第二阶段:JavaScript编程模块/正则对象 24171楼
Python 全系列/第三阶段:Python 网络与并发编程/并发编程 24172楼


image.png









ajaxdemo.rar

老师,你进userServlet和user.jsp 帮我看下,我的不能更新,删除也是先点删除然后刷新页面才删除的

JAVA 全系列/第六阶段:JavaWeb开发/Ajax技术详解(旧) 24173楼

During handling of the above exception, another exception occurred: 

Traceback (most recent call last):
  File "d:\program files\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
    yield
  File "d:\program files\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "d:\program files\python39\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "d:\program files\python39\lib\http\client.py", line 458, in 
read
    n = self.readinto(b)
  File "d:\program files\python39\lib\http\client.py", line 502, in 
readinto
    n = self.fp.readinto(b)
  File "d:\program files\python39\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "d:\program files\python39\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "d:\program files\python39\lib\ssl.py", line 1099, in read   
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred: 

Traceback (most recent call last):
  File "d:\program files\python39\lib\site-packages\pip\_internal\cli\base_command.py", line 189, in _main
    status = self.run(options, args)
  File "d:\program files\python39\lib\site-packages\pip\_internal\cli\req_command.py", line 178, in wrapper
    return func(self, options, args)
  File "d:\program files\python39\lib\site-packages\pip\_internal\commands\install.py", line 316, in run
    requirement_set = resolver.resolve(
  File "d:\program files\python39\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 121, in resolve
    self._result = resolver.resolve(
  File "d:\program files\python39\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 453, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds) 
  File "d:\program files\python39\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 318, in resolve
    name, crit = self._merge_into_criterion(r, parent=None)
  File "d:\program files\python39\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 173, in _merge_into_criterion
    crit = Criterion.from_requirement(self._p, requirement, parent) 
  File "d:\program files\python39\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 82, in from_requirement
    if not cands:
  File "d:\program files\python39\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 124, in __bool__
    return bool(self._sequence)
  File "d:\program files\python39\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 143, in __bool__     
    return any(self)
  File "d:\program files\python39\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 38, in _iter_built   
    candidate = func()
  File "d:\program files\python39\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 167, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "d:\program files\python39\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 300, in __init__
    super().__init__(
  File "d:\program files\python39\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 144, in __init__
    self.dist = self._prepare()
  File "d:\program files\python39\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 226, in _prepare
    dist = self._prepare_distribution()
  File "d:\program files\python39\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 311, in _prepare_distribution
    return self._factory.preparer.prepare_linked_requirement(       
  File "d:\program files\python39\lib\site-packages\pip\_internal\operations\prepare.py", line 457, in prepare_linked_requirement       
    return self._prepare_linked_requirement(req, parallel_builds)   
  File "d:\program files\python39\lib\site-packages\pip\_internal\operations\prepare.py", line 480, in _prepare_linked_requirement      
    local_file = unpack_url(
  File "d:\program files\python39\lib\site-packages\pip\_internal\operations\prepare.py", line 230, in unpack_url
    file = get_http_url(
  File "d:\program files\python39\lib\site-packages\pip\_internal\operations\prepare.py", line 108, in get_http_url
    from_path, content_type = download(link, temp_dir.path)
  File "d:\program files\python39\lib\site-packages\pip\_internal\network\download.py", line 163, in __call__
    for chunk in chunks:
  File "d:\program files\python39\lib\site-packages\pip\_internal\cli\progress_bars.py", line 159, in iter
    for x in it:
  File "d:\program files\python39\lib\site-packages\pip\_internal\network\utils.py", line 64, in response_chunks
    for chunk in response.raw.stream(
  File "d:\program files\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)        
  File "d:\program files\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "d:\program files\python39\lib\contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "d:\program files\python39\lib\site-packages\pip\_vendor\urllib3\response.py", line 443, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")     
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

老师,我在安装 python-pptx 这个包的时候,报了上面的错误,请问如何解决呢?

Python 全系列/ 第十五阶段:自动化操作办公软件、邮件、定时任务等/自动化操作办公软件、邮件、定时任务等 24175楼
JAVA 全系列/第一阶段:AI驱动的JAVA编程/数组和数据存储 24176楼
Python 全系列/第三阶段:Python 网络与并发编程/并发编程 24177楼
Python 全系列/第一阶段:AI驱动的Python编程/面向对象 24178楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637