初学python,抓取搜狗微信公众号文章存入mysql
mysql表:
代码:
import requests
import json
import re
import pymysql
# 创建连接
conn = pymysql.connect(host='\u4f60\u7684\u6570\u636e\u5e93\u5730\u5740', port=端口, user='\u7528\u6237\u540d', passwd='\u5bc6\u7801', db='\u6570\u636e\u5e93\u540d\u79f0', charset='utf8')
# 创建游标
cursor = conn.cursor()
cursor.execute(select * from hd_gzh)
effect_row = cursor.fetchal
1