标签:简单爬虫入门
#!/usr/bin/python3#!-*-coding:utf-8-*-
#导入库#
import requests
from bs4 import BeautifulSoup
#模拟浏览器访问#
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36'}
#GET网页 以及解析 打印#
Response = requests.get('http://www.dajiqq.com/',headers=headers)
soup = BeautifulSoup(res.text,'html.parser')
print(soup.prettify())
###########################################
urls = 'http://www.dajiqq.com'
test1 = requests.get('url=urls')
print(req.text)
标签:简单爬虫入门
原文地址:http://blog.51cto.com/xiaogongju/2117323