python爬取当前文章记录

#encoding:UTF-8
#测试爬虫例子
#!/usr/bin/python3
# encoding:utf-8
'''
Created on 2020-04-21 08:20
@author: king
res = requests.get(url,params=data,headers = headers)
res = requests.post(url, data=json_data, headers = headers)
'''
import requests
from bs4 import BeautifulSoup
class csdn(object):
	"""docstring for ClassName"""
	def __init__(self, helf):
		self.helf = helf
		

	def gethtml(self,helf):
	 	headers = {
	 	'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'
	 	}
	 	response = requests.get(helf,data={},headers=headers)
	 	return response.text

	def get_content(self):
	 	href = "https://blog.csdn.net/qqjjj"
	 	html = self.gethtml(href)
	 	#print(type(response.text),type(response.content))
	 	soup = BeautifulSoup(html,"html.parser")
	 	lables = soup.find('div', class_="article-list").find_all("h4")
	 	for x in lables:
	 		href=dict(x.find("a").attrs)["href"]
	 		self.href=href
	 		html2=self.gethtml(href)
	 		soup2 = BeautifulSoup(html2,"html.parser")
	 		title=soup2.find('h1', id="articleContentId")
	 		print(title)
	 		time=soup2.find('span', class_="time")
	 		content=soup2.find('div', id="article_content")