使用python爬取网页源码

使用python爬取网页源码
1.安装requests和beautiful soup库
2.爬取的代码如下:
import requests//引入requests库+
r=requests.get(“http://y30800i740.eicp.vip/”)//加载所要爬取的页面
r.encoding=‘utf-8’
demo=r.text
from bs4 import BeautifulSoup
soup=BeautifulSoup(demo,“html.parser”)
print(soup.prettify())
3.在IDLE一次运行上述代码,或者在pycharm输入上述代码运行就行

你可能感兴趣的:(python)