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 text
engine = 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 tt
def get_date(date):
# 日期时间的获取
date_url = "http://cnkmprice.k

本文介绍如何使用Python进行网络爬虫,具体案例是爬取康美中药网站的数据。提供完整代码链接,可在GitHub上下载。
最低0.47元/天 解锁文章
4390

被折叠的 条评论
为什么被折叠?



