爬蟲 獲取某著名旅遊城市的樓盤資訊

2021-09-10 03:40:09 字數 1272 閱讀 5024

話不多說~直接上**:

import requests

from bs4 import beautifulsoup as bs

import pandas as pd

def getonepage(url, lists):

response = requests.get(url)

print(type(response.text))

soup = bs(response.text, 'html.parser')

houselist = soup.find_all('li', class_='item')

print(houselist)

for house in houselist:

list =

if house.find('div', class_='info').find('span', class_='tag') == none:

elif house.find('div', class_='info').find('span', class_='tag').text == '':

else:

if house.find('div', class_='info').find('span', class_='area') == none:

elif house.find('div', class_='info').find('span', class_='area').text == '':

else:

return lists

def getallinfo():

list_all =

list_one =

for i in range(1, 13):

url_new = "" + str(i) + "/"

print(url_new)

list_all = list_all + getonepage(url_new, list_one)

h = pd.dataframe(columns=name, data=list_all)

h.to_csv('f:/houseinfo.csv', encoding='gb18030')

print(list_all)

def run():

getallinfo()

if __name__ == '__main__':

run()

**實現較為簡單,**不用登陸,並且多次頻繁請求之下也未出現封ip等情況。

後期將逐步更新技術.......

某航空積分商城爬蟲

import urllib.request import urllib.parse import urllib.error import json import jsonpath import pandas as pd import time url 可從fiddler中檢視 headers nam...

python 某美電商平台爬蟲

def run q,searchtype,page headermap guomeiheader.guomei url q,searchtype,page guomeijson mayi3.daili url,headermap.get headers utf 8 headermap.get may...

js 取值 賦值 獲取某標籤某屬性的值

1.取值 方法一 自定義屬性必須用getattribute 方法 var iframesrcattr document.getelementbyid importjsp getattribute src 獲取得到的值是 test.html 方法二 var iframesrcattr document...