import json
import random
import time
from bs4 import BeautifulSoup
import requests
import re
import pymysql
url = "https://place.qyer.com/uk/citylist-0-0-1/"
class Point:
def __init__(self,commentCount, img,cnname, enname, grade, rank, introduce, address, arrivedWay, openTime, ticket, tel, webUrl,
latestTime, cityName):
self.commentCount = commentCount;
self.img=img;
self.chName = cnname # 中文名称
self.enName = enname # 英文名称
self.grade = grade # 评分
self.rank = rank # 排名
self.introduce = introduce # 简介
self.address = address # 地址
self.arrivedWay = arrivedWay # 到达方式
self.openTime = openTime # 开放时间
self.ticket = ticket # 门票
self.tel = tel # 电话
self.webUrl = webUrl # 网址
self.latestTime = latestTime # 网址
self.cityName = cityName # 所属城市
db = pymysql.connect(host='localhost',
port=3306, user='root',
passwd='root', db='test', charset='utf8')
cursor = db.cursor() # 创建游标对象
# proxies = [ 'http://35.225.204.126:80',
# 'http://35.193.0.225:80',
# 'http://104.154.40.136:8080',
# 'http://35.193.0.225:80',
# 'http://35.184.159.21:8080',
# 'http://23.253.207.55:3128',
# 'http://134.209.209.76:8080',
# 'http://138.197.10.18:8080',
# 'http://157.230.57.151:8080',
# 'http://134.209.33.104:8080',
# ] #模拟IP
proxies = [ 'http://206.189.231.239:8080',
'http://157.230.55.134:80',
'http://157.230.210.133:8080',
'http://54.39.98.135:80'
]
def insertData(Point):
# 插入数据
commentCount=getattr(Point, 'commentCount',0)
img = getattr(Point, 'img', '')
chName=getattr(Point,'chName','')
enName=getattr(Point,'enName','')
grade=getattr(Point,'grade','')
rank=getattr(Point,'rank','')
introduce=getattr(Point,'introduce','')
address=getattr(Point,'address','')
arrivedWay=getattr(Point,'arrivedWay','')
openTime=getattr(Point,'openTime','')
ticket=getattr(Point,'ticket','')
tel=getattr(Point,'tel','')
Python爬虫爬取某网站
最新推荐文章于 2023-11-04 09:45:00 发布