import re import time import fake_useragent import requests from bs4 import BeautifulSoup from pymysql import * # '1=>美容2=>美体3=>美颜4=>美疗5=>母婴6=>产后7=>养肤8=>皮肤9=>护理10=>私密11=>月子12=>减肥13=>瘦身14=>小儿推拿15=>医美16=>护肤17=>孕婴18=>女人19=>女子养生20=>SPA', city = 'qingdao' keywords = '私密' categoryId = 10 url = 'http://i.meituan.com/s/' + city + '-'+ keywords def getXml(url): mark = True xml = '' i = 1 while mark: ua = fake_useragent.FakeUserAgent() header_info = {'User-Agent': ua.random} data = requests.get(url, headers=header_info) text = data.text xml = BeautifulSoup(text, 'html.parser') if len(xml)<1: print("++++++++休息了:" + str(5 * i) + "分钟") time.sleep(300) i = i + 1 mark = True else: mark = False return xml xml = getXml(url) print(xml)
python 美团 但有问题
最新推荐文章于 2024-06-20 14:33:06 发布