Python爬虫爬取某网站

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','')
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值