摘要:
# 1.安装 pip install pymysql import pymysql try: # 1.链接 数据库 链接对象 connection() conn = pymysql.Connect( host="localhost", port=3306, db='animal', user='root', ... 阅读全文
摘要:
# pip install redis import redis # 1.链接数据库 key--value client = redis.StrictRedis(host='127.0.0.1', port=6379) # 2.设置key key = 'pyone' # 3.string 增加 result = client.set(key, "1") # 4.删 1, 0 resu... 阅读全文
摘要:
import requests from lxml import etree from bs4 import BeautifulSoup import json class BookSpider(object): def __init__(self): self.base_url = 'http://www.allitebooks.com/page/{}' ... 阅读全文
摘要:
import json import csv # 需求 json 中的数据 转换 成 csv文件 # 1.分别 读 , 创建文件 json_fp = open('02new.json', 'r') csv_fp = open('03csv.csv', 'w') # 2.提出 表头 , 表内容 data_list = json.load(json_fp) sheet_title = da... 阅读全文
摘要:
import json # 1.字符串和 dic list转换 # 字符串(json)----dict list data = '[{"name":"张三","age":20},{"name":"李四","age":18}]' list_data = json.loads(data) # dict list ---字符串 list2 = [{"name": "张三", "age": 20}... 阅读全文
摘要:
import requests from bs4 import BeautifulSoup from lxml import etree import json class BtcSpider(object): def __init__(self): self.url = 'http://8btc.com/forum-61-{}.html' self.h... 阅读全文
摘要:
# pip install beautifulsoup4 from bs4 import BeautifulSoup html_doc = """ The Dormouse's story p标签的内容 The Dormouse's story Once upon a time there were three little sisters; and their... 阅读全文
摘要:
# pip install beautifulsoup4 from bs4 import BeautifulSoup html_doc = """ The Dormouse's story The Dormouse's story Once upon a time there were three little sisters; and their names were Elsie,... 阅读全文
摘要:
# pip install beautifulsoup4 from bs4 import BeautifulSoup html_doc = """ The Dormouse's story The Dormouse's story Once upon a time there were three little sisters; and their names were Elsie, L... 阅读全文
摘要:
import requests from lxml import etree import json class BtcSpider(object): def __init__(self): self.base_url = 'http://8btc.com/forum-61-' self.headers = { "User-Ag... 阅读全文