#hao.360网页爬虫
import requests
r=requests.get('https://hao.360.com/')
r.encoding=r.apparent_encoding
from bs4 import BeautifulSoup
soup =BeautifulSoup(r.text,'html.parser')
print(soup.prettify())
#图片爬虫
import requests
url='https://t7.baidu.com/it/u=1951548898,3927145&fm=193&f=GIF'
path='../picture/狗.jpg'
try:
r=requests.get(url)
f=open(path,'wb')
f.write(r.content) #写入二进制文件
f.close()
except:
print('爬取失败')
#音频爬虫
import requests
url='http://mp3.shengyin.com/abcdefg/1234567/upload/%E5%85%AB%E5%93%A5%E5%8F%AB%E5%A3%B0.mp3'
path='../picture/八哥.mp3'
try:
r=requests.get(url)
f=open(path,'wb')
f.write(r.content) #写入二进制文件
f.close()
except:
print('爬取失败')