import requests
import re
from bs4 import BeautifulSoup
url="https://www.qiushibaike.com/video/"
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36"}
resp=requests.get(url,headers=headers)
content = resp.content.decode('utf-8')
soup=BeautifulSoup(content,'html.parser')
text=resp.text
# print(text)
list=re.findall(r'',text)
divs=soup.find_all('div',class_="content")
title=[]
for item in divs:
title.append(item.find('span').text.strip())
lst=[]
for item in list:
lst.append("https:"+item)
count=0
for item in lst:
resp=requests.get(item,headers=headers)
with open("video/"+str(title[count])+".mp4","wb") as file:
file.write(resp.content)
print("已下载完第"+str(count)+"个")
count+=1
print("视频下载完毕")
二、链家二手房数据
本次主要利用“BeautifulSoup”和mysql数据库
import re
import requests
import mysql.connector
from bs4 import BeautifulSoup
class LianJia():
mydb=mysql.connector.connect(host='localhost',user='root',password='fengge666',database='hotel')
mycursor=mydb.cursor()
#初始化def__init__(self):
self.url="https://bj.lianjia.com/chengjiao/pg{0}/"
self.headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36'}
def send_request(self,url):
resp=requests.get(url,headers=self.headers)
if resp:
self.parse_content(resp)
def parse_content(self,resp):
lst=[]
html=resp.text
bs=BeautifulSoup(html,'html.parser')
ul=bs.find('ul',class_='listContent')
li_lst=ul.find_all('li')
for item in li_lst:
title=item.find('div',class_='title').text
houseInfo=item.find('div',class_='houseInfo').text
data=item.find('div',class_='dealDate').text
money=item.find('div',class_='totalPrice').text
flood=item.find('div',class_='positionInfo').text
price=item.find('div',class_='unitPrice').text
span=item.find('span',class_='dealCycleTxt')
span_lst=span.find_all('span')
agent=item.find('a',class_='agent_name').text
lst.append((title,houseInfo,data,money,flood,price,span_lst[0].text,span_lst[1].text,agent))
#开始存储到数据库 self.write_mysql(lst)
def write_mysql(self,lst):
# print(self.mydb)
tuple_lst=tuple(lst)
sql="insert into house (title,houseInfo,data,money,flood,price,current_money,current_data,agent) values (%s,%s,%s,%s,%s,%s,%s,%s,%s)"
self.mycursor.executemany(sql,tuple_lst)
self.mydb.commit()
def start(self):
for i in range(1,11):
full_url=self.url.format(i)
resp=self.send_request(full_url)
if resp:
self.parse_content(self,resp)
if__name__ == '__main__':
lianjia=LianJia()
lianjia.start()
只需要在调用该对象合适(比如下列的setStyles)的方法后让该方法返回该对象(通过this 因为一旦一个函数称为一个对象方法的话那么在这个方法内部this(结合下面的setStyles)指向这个对象)
function create(type){
var element=document.createElement(type);
//this=element;
JAX-WS
SOAP Version 1.2 Part 0: Primer (Second Edition)
SOAP Version 1.2 Part 1: Messaging Framework (Second Edition)
SOAP Version 1.2 Part 2: Adjuncts (Second Edition)
Which style of WSDL
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml