上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 67 下一页
摘要: # 1.安装 pip install pymysql import pymysql try: # 1.链接 数据库 链接对象 connection() conn = pymysql.Connect( host="localhost", port=3306, db='animal', user='root', ... 阅读全文
posted @ 2019-03-30 13:30 hank-li 阅读(87) 评论(0) 推荐(0) 编辑
摘要: # 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... 阅读全文
posted @ 2019-03-30 13:21 hank-li 阅读(66) 评论(0) 推荐(0) 编辑
摘要: 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/{}' ... 阅读全文
posted @ 2019-03-30 12:34 hank-li 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2019-03-30 12:32 hank-li 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 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}... 阅读全文
posted @ 2019-03-30 12:23 hank-li 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2019-03-30 12:02 hank-li 阅读(124) 评论(0) 推荐(0) 编辑
摘要: # 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... 阅读全文
posted @ 2019-03-30 12:00 hank-li 阅读(121) 评论(0) 推荐(0) 编辑
摘要: # 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,... 阅读全文
posted @ 2019-03-30 11:56 hank-li 阅读(122) 评论(0) 推荐(0) 编辑
摘要: # 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... 阅读全文
posted @ 2019-03-30 11:53 hank-li 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2019-03-30 11:40 hank-li 阅读(141) 评论(0) 推荐(0) 编辑
上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 67 下一页