zoukankan      html  css  js  c++  java
  • 博客园源码不可copy的解决办法

      今天在逛班级博客园时,进入看到李昂的博客,是一个关于盲打的博客(https://www.cnblogs.com/ITXiaoAng/p/11962143.html)。该博客里面还有盲打系统的源码,本来想试试练练盲打,但是我不知道这篇博客的模板不支持copy还是作者本人插入代码时设定不可copy,copy源码不下来。于是我灵机一动,刚刚好最近学了爬虫,可以学以致用。

    • 首先分析网页源码爬取

      我们发现所有源码在<code>标签

    • 爬取code标签内容
    code=b.find_all('code')
    • 直接将源码在控制台输出
    import requests;
    from bs4 import BeautifulSoup
    
    # 请求
    result=requests.get("https://www.cnblogs.com/ITXiaoAng/p/11962143.html")
    result.encoding='utf-8'
    result=result.text
    
    b=BeautifulSoup(result,'html.parser')
    code=b.find_all('code')
    for i in code:
        print(i.text)
    • 爬取结果
    •  到这里就已经完成了爬取源码的过程了,再把源码拿来运行试试,嘿嘿。

       这样就完成了强行copy源码的过程了。接下来上手试试软件,练练打字。

  • 相关阅读:
    单调队列
    Johnson全源最短路
    重链剖分
    矩阵快速幂
    Tarjan
    题解 UVA439 骑士的移动 Knight Moves
    题解 SP10500 HAYBALE
    题解 P4058 [Code+#1]木材
    题解 P3395 路障
    题解 SP24 FCTRL2
  • 原文地址:https://www.cnblogs.com/DrcProgrammingCool/p/11962814.html
Copyright © 2011-2022 走看看