本文主要是介绍python 爬取康美中药网站,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
python 爬取康美中药网站
#!/usr/bin/env python # -*- coding: utf-8 -*-import requests from lxml import etree import json import pandas as pd import datetime from kangmeizhongyao.common.AreaCodeDecoder import AreaCodeDecoder import hashlib from sqlalchemy import create_engine import numpy as np from sqlalchemy.sql import textengine = create_engine('mysql+pymysql://xx:xxx@xxx:33169/xxx?charset=utf8') data = {'loadType': '3','code': 'CD-013','locale': 'zh_CN','expClass': '6','publish_type': '1','date': datetime.datetime.now().strftime("%Y-%m-%d"),'jsoncallback': 'a' }header = {'Referer': 'http://www.kmzyw.com.cn/vchart/zdjk.shtml','User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36' }def get_content(content):content.encoding = 'utf-8'tt = str(content.text)[2:-3]return ttdef get_date(date):# 日期时间的获取date_url = "http://cnkmprice.kmzyw.com.cn/pageIndexForJsonp.action?loadType=4&locale=zh_CN" \"&expClass=0&publish_type=1&date={0}&updowntype=0&jsoncallback=a" \"&wscckey=7c14a5ac9b3f77fb_1557200787".format(date)date_content = get_content(requests.get(date_url, hea
这篇关于python 爬取康美中药网站的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!