置顶 老师参与

Requests库的爬取性能分析

嵩天 发表于04月21日
<p>尽管Requests库功能很友好、开发简单(其实除了import外只需一行主要代码),但其性能与专业爬虫相比还是有一定差距的。请编写一个小程序,“任意”找个url,测试一下成功爬取100次网页的时间。(某些网站对于连续爬取页面将采取屏蔽IP的策略,所以,要避开这类网站。)</p><p>请回复代码,并给出url及在自己机器上的运行时间。</p><p><br/></p><p><br/></p><p><br/></p>
42 回复

    1楼

  • 安工19102刘邑乐 发表于04月24日
    0 | 0 | 举报
    <p>比较requests和Scrapy的性能区别嘛</p>
    安工19102刘邑乐 发表于04月24日
    添加评论
  • 2楼

  • 辛丨酉 发表于04月24日
    1 | 0 | 举报
    <p style="line-height: 27px;" ><span style="color: rgb(179, 89, 0);" >import</span> <span style="color: rgb(138, 70, 0);" >requests</span></p><p style="line-height: 27px;" ><span style="color: rgb(179, 89, 0);" >import</span> <span style="color: rgb(138, 70, 0);" >time</span></p><p style="line-height: 27px;" ><br></p><p style="line-height: 27px;" ><span style="color: rgb(110, 119, 129);" ># 测试的URL</span></p><p style="line-height: 27px;" >url <span style="color: rgb(179, 89, 0);" >=</span> <span style="color: rgb(10, 48, 105);" >"https://www.baidu.com"</span></p><p style="line-height: 27px;" ><span style="color: rgb(110, 119, 129);" ># 爬取100次网页</span></p><p style="line-height: 27px;" ><span style="color: rgb(179, 89, 0);" >def</span> <span style="color: rgb(130, 80, 223);" >test_requests_performance</span>():</p><p style="line-height: 27px;" >&nbsp; &nbsp; success_count <span style="color: rgb(179, 89, 0);" >=</span> <span style="color: rgb(5, 80, 174);" >0</span></p><p style="line-height: 27px;" >&nbsp; &nbsp; start_time <span style="color: rgb(179, 89, 0);" >=</span> <span style="color: rgb(138, 70, 0);" >time</span>.<span style="color: rgb(130, 80, 223);" >time</span>()</p><p style="line-height: 27px;" ><br></p><p style="line-height: 27px;" >&nbsp; &nbsp; <span style="color: rgb(179, 89, 0);" >for</span> i <span style="color: rgb(179, 89, 0);" >in</span> <span style="color: rgb(138, 70, 0);" >range</span>(<span style="color: rgb(5, 80, 174);" >100</span>):</p><p style="line-height: 27px;" >&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: rgb(179, 89, 0);" >try</span>:</p><p style="line-height: 27px;" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response <span style="color: rgb(179, 89, 0);" >=</span> <span style="color: rgb(138, 70, 0);" >requests</span>.<span style="color: rgb(130, 80, 223);" >get</span>(url)</p><p style="line-height: 27px;" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: rgb(179, 89, 0);" >if</span> response.status_code <span style="color: rgb(179, 89, 0);" >==</span> <span style="color: rgb(5, 80, 174);" >200</span>:</p><p style="line-height: 27px;" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success_count <span style="color: rgb(179, 89, 0);" >+=</span> <span style="color: rgb(5, 80, 174);" >1</span></p><p style="line-height: 27px;" >&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: rgb(179, 89, 0);" >except</span> <span style="color: rgb(138, 70, 0);" >Exception</span> <span style="color: rgb(179, 89, 0);" >as</span> e:</p><p style="line-height: 27px;" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: rgb(130, 80, 223);" >print</span>(<span style="color: rgb(179, 89, 0);" >f</span><span style="color: rgb(10, 48, 105);" >"第 </span><span style="color: rgb(179, 89, 0);" >{</span>i<span style="color: rgb(179, 89, 0);" >+</span><span style="color: rgb(5, 80, 174);" >1</span><span style="color: rgb(179, 89, 0);" >}</span><span style="color: rgb(10, 48, 105);" > 次请求失败: </span><span style="color: rgb(179, 89, 0);" >{</span>e<span style="color: rgb(179, 89, 0);" >}</span><span style="color: rgb(10, 48, 105);" >"</span>)</p><p style="line-height: 27px;" ><br></p><p style="line-height: 27px;" >&nbsp; &nbsp; end_time <span style="color: rgb(179, 89, 0);" >=</span> <span style="color: rgb(138, 70, 0);" >time</span>.<span style="color: rgb(130, 80, 223);" >time</span>()</p><p style="line-height: 27px;" >&nbsp; &nbsp; elapsed_time <span style="color: rgb(179, 89, 0);" >=</span> end_time <span style="color: rgb(179, 89, 0);" >-</span> start_time</p><p style="line-height: 27px;" >&nbsp; &nbsp; <span style="color: rgb(130, 80, 223);" >print</span>(<span style="color: rgb(179, 89, 0);" >f</span><span style="color: rgb(10, 48, 105);" >"成功爬取 </span><span style="color: rgb(179, 89, 0);" >{</span>success_count<span style="color: rgb(179, 89, 0);" >}</span><span style="color: rgb(10, 48, 105);" > 次网页,总耗时: </span><span style="color: rgb(179, 89, 0);" >{</span>elapsed_time<span style="color: rgb(179, 89, 0);" >:.2f}</span><span style="color: rgb(10, 48, 105);" > 秒"</span>)</p><p style="line-height: 27px;" ><br></p><p style="line-height: 27px;" ><span style="color: rgb(179, 89, 0);" >if</span> __name__ <span style="color: rgb(179, 89, 0);" >==</span> <span style="color: rgb(10, 48, 105);" >"__main__"</span>:</p><p style="line-height: 27px;" >&nbsp; &nbsp; <span style="color: rgb(130, 80, 223);" >test_requests_performance</span>()</p><p style="line-height: 27px;" ><br></p><p style="line-height: 27px;" >大概需要10秒钟左右,看网络情况</p><p style="line-height: 27px;" ><br></p><p><br></p>
    辛丨酉 发表于04月24日
    添加评论
  • 3楼

  • mooc47246773675007644 发表于04月26日
    0 | 0 | 举报
    <p>网太撇爬了77秒</p><p><br></p>
    mooc47246773675007644 发表于04月26日
    添加评论
  • 4楼

  • mooc46139760721952312 发表于04月27日
    0 | 0 | 举报
    <p>好难</p>
    mooc46139760721952312 发表于04月27日
    添加评论
  • 5楼

  • mooc97378228091156673 发表于04月27日
    0 | 0 | 举报
    <p>好</p>
    mooc97378228091156673 发表于04月27日
    添加评论
  • 6楼

  • mooc13318055815875997 发表于04月27日
    1 | 0 | 举报
    <p>访问的地址是腾讯新闻网qq.com,免费的ip代理失败,或者说超出了所能承受访问的次数,受到限制失败了。所以最后把代理注释掉,总共花了56.7328731000016秒。以下是代码<img src="https://mooc-image.nosdn.127.net/efe6e7a202954f1bafd2c13a07636476.png" style="max-width:750px;" ></p>
    mooc13318055815875997 发表于04月27日
    添加评论
  • 7楼

  • xyzdol 发表于04月27日
    0 | 0 | 举报
    用了69秒 网络确实有点慢
    xyzdol 发表于04月27日
    添加评论
  • 8楼

  • 怕坡手小吴 发表于04月28日
    0 | 0 | 举报
    111
    怕坡手小吴 发表于04月28日
    添加评论
  • 9楼

  • mooc47615546462983701 发表于04月28日
    0 | 0 | 举报
    <p>好难</p>
    mooc47615546462983701 发表于04月28日
    添加评论
  • 10楼

  • Cyrus.小胖 发表于04月29日
    1 | 0 | 举报
    import time import requests url = 'https://www.google.com' def test_url(url): start_time = time.time() cnt = 0 while cnt &lt; 100: try: response = requests.get(url, timeout=10) response.raise_for_status() cnt += 1 except Exception: continue end_time = time.time() print(end_time - start_time) if __name__ == '__main__': test_url(url) <p>----------------------------------</p><p>执行结果:</p><p>83.87145042419434</p><p><br></p><p>进程已结束,退出代码为 0</p>
    Cyrus.小胖 发表于04月29日
    添加评论
  • 11楼

  • mooc45876369341933143 发表于04月29日
    0 | 0 | 举报
    <p>好的</p><p><br></p>
    mooc45876369341933143 发表于04月29日
    添加评论
  • 12楼

  • 武亚芹 发表于04月30日
    0 | 0 | 举报
    import time import requests url = &#39;https://www.google.com&#39; def test_url(url): start_time = time.time() cnt = 0 while cnt &lt; 100 try response =&quot;requests.get(url,&quot; timeout=&quot;10)&quot; responseraise_for_status cnt =&quot;1&quot; except Exception continue end_time =&quot;time.time()&quot; printend_time - start_time if __name__ =&quot;= &#39;__main__&#39;:&quot; test_urlurl p&gt;----------------------------------
    武亚芹 发表于04月30日
    添加评论
  • 13楼

  • CryedmoonRay 发表于05月02日
    0 | 0 | 举报
    <p><img src="https://mooc-image.nosdn.127.net/635afafb588d456d88b18c73aca3e1a6.png" style="max-width:750px;" ></p><p>每次时间都不一样</p>
    CryedmoonRay 发表于05月02日
    添加评论
  • 14楼

  • Pinkfl 发表于05月03日
    0 | 0 | 举报
    <p><img src="https://mooc-image.nosdn.127.net/64f8b9ec6aa5451f84a36bdb22aab855.png" style="max-width:750px;" ></p><p>https://www.asus.com.cn 总是403</p><p>https://www.baidu.com 68.多</p><p><br></p><p><br></p>
    Pinkfl 发表于05月03日
    添加评论
  • 15楼

  • jingxinyo 发表于05月05日
    0 | 0 | 举报
    231.45秒 <img src='https://mooc-image.nosdn.127.net/26F6776D3F4A4DC43CD5D3C389637E58.jpg' />
    jingxinyo 发表于05月05日
    添加评论
  • 16楼

  • mooc李峰 发表于05月05日
    0 | 0 | 举报
    40秒
    mooc李峰 发表于05月05日
    添加评论
  • 17楼

  • zju-pku 发表于05月06日
    0 | 0 | 举报
    <p>import requests</p><p>import time</p><p><br></p><p>def test_requests_performance(url, times=100):</p><p> start_time = time.time()</p><p> </p><p> for i in range(times):</p><p> try:</p><p> response = requests.get(url)</p><p> response.raise_for_status() # 检查请求是否成功</p><p> except requests.exceptions.RequestException as e:</p><p> print(f"第{i+1}次请求失败: {e}")</p><p> return None</p><p> </p><p> end_time = time.time()</p><p> total_time = end_time - start_time</p><p> avg_time = total_time / times</p><p> </p><p> print(f"成功爬取{times}次网页")</p><p> print(f"总耗时: {total_time:.2f}秒")</p><p> print(f"平均每次请求耗时: {avg_time:.4f}秒")</p><p> return total_time</p><p><br></p><p># 测试URL - 使用httpbin.org的get接口</p><p>test_url = "https://httpbin.org/get"</p><p>total_time = test_requests_performance(test_url)</p><p><br></p><p># 输出结果示例:</p><p># 成功爬取100次网页</p><p># 总耗时: 12.34秒</p><p># 平均每次请求耗时: 0.1234秒</p>
    zju-pku 发表于05月06日
    添加评论
  • 18楼

  • 冯胡楚晨 发表于05月11日
    0 | 0 | 举报
    import time import requests url = &#39;https://www.google.com&#39; def test_url(url): start_time = time.time() cnt = 0 while cnt ----------------------------------
    冯胡楚晨 发表于05月11日
    添加评论
  • 19楼

  • WWZLSJ 发表于05月11日
    0 | 0 | 举报
    <p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" >import time</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" >import requests</span></p><p><br></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" >url = 'https://www.google.com'</span></p><p><br></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" >def test_url(url):</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > start_time = time.time()</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > cnt = 0</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > while cnt &lt; 100:</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > try:</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > response = requests.get(url, timeout=10)</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > response.raise_for_status()</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > cnt += 1</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > except Exception:</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > continue</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > end_time = time.time()</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > print(end_time - start_time)</span></p><p><br></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" >if __name__ == '__main__':</span></p><p><span style="font-size: 12px; font-family: Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, 微软雅黑, Helvetica, &quot;sans-serif&quot;; color: rgb(102, 102, 102);" > test_url(url)</span></p><p style="line-height: 22px;" >----------------------------------</p><p style="line-height: 22px;" >执行结果:</p><p style="line-height: 22px;" >83.87145042419434</p><p style="line-height: 22px;" ><br></p><p style="line-height: 22px;" >进程已结束,退出代码为 0</p><p><br></p>
    WWZLSJ 发表于05月11日
    添加评论
  • 20楼

  • 海在阳光下wzhgdsdxy 发表于05月16日
    0 | 0 | 举报
    <p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" >import requests</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" >import time</span></p><p><br></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" >url = "https://www.example.com" # 这里以示例网站为例,你可以换成合适的url,确保该网站不会屏蔽频繁请求</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" >start_time = time.time()</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" >for _ in range(100):</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" > try:</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" > response = requests.get(url)</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" > if response.status_code == 200:</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" > pass # 这里可以添加对响应内容的处理逻辑,比如解析页面等</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" > else:</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" > print(f"请求失败,状态码: {response.status_code}")</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" > except requests.RequestException as e:</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" > print(f"请求出错: {e}")</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" >end_time = time.time()</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" >total_time = end_time - start_time</span></p><p><span style="font-size: medium; font-family: Inter, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;SF Pro SC&quot;, &quot;SF Pro Display&quot;, &quot;SF Pro Icons&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; color: rgb(28, 31, 35);" >print(f"成功爬取100次网页的总时间为: {total_time} 秒")</span></p>
    海在阳光下wzhgdsdxy 发表于05月16日
    添加评论
点击加载更多