直接上代码吧:

一、爬取某外卖平台的指定商家菜品信息

from urllib import request
import json
import random url = "https://www.ele.me/restapi/shopping/v2/menu?restaurant_id=1392240&terminal=web" # 多搞几个user-agent 看上去更真实点~_^
user_agents = [
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36 QQBrowser/4.3.4986.400',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:59.0) Gecko/20100101 Firefox/59.0'] random_user_agent = user_agents[random.randint(0, len(user_agents) - 1)]
page = request.Request(url, headers={'User-Agent': random_user_agent})
page_info = request.urlopen(page).read().decode("utf-8") # 该url正好返回的是json数组,直接解析就可以了
menu_json = json.loads(page_info) # 清理一些特殊字符串
def clean_menu_name(name):
temp = ["-", "^_^", "\n", "◆"]
for s in temp:
name = name.replace(s, "")
return name for category in menu_json:
print("分类名:", clean_menu_name(category["name"]))
for food in category["foods"]:
print("\t", "菜名:", clean_menu_name(food["name"]), " , 菜ID:", food["item_id"], " , 分类ID:", food["category_id"])
for spec in food["specfoods"]:
print("\t\t", "规格ID:", spec["sku_id"], " , 价格:", spec["price"])

输出:

分类名: 必选品(【必选!】吃法二选一,嘛哩匠心出品)
菜名: 经典骨汤上等豚骨每日现熬 , 菜ID: 17548636051 , 分类ID: 13737658
规格ID: 20830000019 , 价格: 1
菜名: 特色干拌—麻辣拌(招牌,秘制麻酱) , 菜ID: 17548637075 , 分类ID: 13737658
规格ID: 20830001043 , 价格: 1.5
分类名: 热销
菜名: 经典骨汤上等豚骨每日现熬 , 菜ID: 17548636051 , 分类ID: 13737658
规格ID: 20830000019 , 价格: 1
菜名: 娃娃菜 , 菜ID: 17548706707 , 分类ID: 13737835
规格ID: 20830070675 , 价格: 3
菜名: 精品肥牛 , 菜ID: 17548664723 , 分类ID: 13737800
规格ID: 20830028691 , 价格: 5.5
菜名: 金针菇 , 菜ID: 17548711827 , 分类ID: 13737835
规格ID: 20830075795 , 价格: 3
菜名: 土豆 , 菜ID: 17548693395 , 分类ID: 13737835
规格ID: 20830057363 , 价格: 2.5
菜名: 特色干拌—麻辣拌(招牌,秘制麻酱) , 菜ID: 17548637075 , 分类ID: 13737658
规格ID: 20830001043 , 价格: 1.5
菜名: 精品蟹肉棒 , 菜ID: 17548654483 , 分类ID: 13737790
规格ID: 20830018451 , 价格: 4
菜名: 冬瓜 , 菜ID: 17548694419 , 分类ID: 13737835
规格ID: 20830058387 , 价格: 2.5
菜名: 梅林午餐肉 , 菜ID: 17548656531 , 分类ID: 13737790
规格ID: 20830020499 , 价格: 5.5
菜名: 【人气】秘制麻酱芝麻花生酱 , 菜ID: 17548638099 , 分类ID: 13737698
规格ID: 20830002067 , 价格: 1
分类名: 优惠
菜名: 招牌霸道~经典荤素~套餐 , 菜ID: 200000173605996435 , 分类ID: 1238754176
规格ID: 200000199013771155 , 价格: 29.4
菜名: 招牌霸道~素食主义~套餐 , 菜ID: 200000173616109459 , 分类ID: 1238754176
规格ID: 200000199009531795 , 价格: 25.2
分类名: Hi~嘛哩来袭咯~
菜名: 有问题?找嘛哩!~ , 菜ID: 200000173483983763 , 分类ID: 1238743250
规格ID: 200000198867809171 , 价格: 0.01
分类名: 【不得不吃】秘制酱料匠心出品
菜名: 【人气】秘制麻酱芝麻花生酱 , 菜ID: 17548638099 , 分类ID: 13737698
规格ID: 20830002067 , 价格: 1
菜名: 香辣酱 , 菜ID: 17548639123 , 分类ID: 13737698
规格ID: 20830003091 , 价格: 1
菜名: 沙茶酱 , 菜ID: 17548640147 , 分类ID: 13737698
规格ID: 20830004115 , 价格: 1
菜名: 菌菇酱 , 菜ID: 17548642195 , 分类ID: 13737698
规格ID: 20830006163 , 价格: 1
分类名: 【必选】麻辣在舌尖(口味选择)
菜名: 不麻+不辣 , 菜ID: 17548643219 , 分类ID: 13737734
规格ID: 20830007187 , 价格: 0
菜名: 微麻+微辣 , 菜ID: 17548644243 , 分类ID: 13737734
规格ID: 20830008211 , 价格: 0
菜名: 中麻+中辣 , 菜ID: 17548645267 , 分类ID: 13737734
规格ID: 20830009235 , 价格: 0
菜名: 重麻+重辣 , 菜ID: 17548646291 , 分类ID: 13737734
规格ID: 20830010259 , 价格: 0
分类名: 【可选】调味小料区(放碗里,不单独打包)
菜名: 香葱 , 菜ID: 17548647315 , 分类ID: 13737756
规格ID: 20830011283 , 价格: 0.1
菜名: 蒜泥 , 菜ID: 17548648339 , 分类ID: 13737756
规格ID: 20830012307 , 价格: 0.1
菜名: 醋 , 菜ID: 17548649363 , 分类ID: 13737756
规格ID: 20830013331 , 价格: 0.1
分类名: 人气特色榜单
菜名: 冻豆腐 , 菜ID: 17548650387 , 分类ID: 13737790
规格ID: 20830014355 , 价格: 3.5
菜名: 成都酥肉 , 菜ID: 17548651411 , 分类ID: 13737790
规格ID: 20830015379 , 价格: 4.5
菜名: 芝士年糕 , 菜ID: 17548653459 , 分类ID: 13737790
规格ID: 20830017427 , 价格: 4
菜名: 精品蟹肉棒 , 菜ID: 17548654483 , 分类ID: 13737790
规格ID: 20830018451 , 价格: 4
菜名: 荠菜丸子 , 菜ID: 17548655507 , 分类ID: 13737790
规格ID: 20830019475 , 价格: 3.5
菜名: 梅林午餐肉 , 菜ID: 17548656531 , 分类ID: 13737790
规格ID: 20830020499 , 价格: 5.5
菜名: 哈尔滨红肠 , 菜ID: 17548657555 , 分类ID: 13737790
规格ID: 20830021523 , 价格: 4
菜名: 甜玉米 , 菜ID: 17548658579 , 分类ID: 13737790
规格ID: 20830022547 , 价格: 3.5
菜名: 牛百叶 , 菜ID: 17548659603 , 分类ID: 13737790
规格ID: 20830023571 , 价格: 5
分类名: 精品荤菜
菜名: 燕饺 , 菜ID: 17548690323 , 分类ID: 13737800
规格ID: 20830054291 , 价格: 4
菜名: 广味香肠 , 菜ID: 17548691347 , 分类ID: 13737800
规格ID: 20830055315 , 价格: 4
菜名: 川味香肠 , 菜ID: 17548692371 , 分类ID: 13737800
规格ID: 20830056339 , 价格: 4
菜名: 培根 , 菜ID: 17548660627 , 分类ID: 13737800
规格ID: 20830024595 , 价格: 3.5
菜名: 鸡胗 , 菜ID: 17548661651 , 分类ID: 13737800
规格ID: 20830025619 , 价格: 4
菜名: 里脊肉 , 菜ID: 17548662675 , 分类ID: 13737800
规格ID: 20830026643 , 价格: 3.5
菜名: 骨肉相连 , 菜ID: 17548663699 , 分类ID: 13737800
规格ID: 20830027667 , 价格: 4
菜名: 精品肥牛 , 菜ID: 17548664723 , 分类ID: 13737800
规格ID: 20830028691 , 价格: 5.5
菜名: 鲜腐皮虾卷 , 菜ID: 200000176127363987 , 分类ID: 13737800
规格ID: 200000202129068947 , 价格: 4.9
菜名: 蟹粉包 , 菜ID: 17548668819 , 分类ID: 13737800
规格ID: 20830032787 , 价格: 3
菜名: 海胆包 , 菜ID: 17548669843 , 分类ID: 13737800
规格ID: 20830033811 , 价格: 3
菜名: 蛋饺 , 菜ID: 17548670867 , 分类ID: 13737800
规格ID: 20830034835 , 价格: 3.5
菜名: 千叶豆腐 , 菜ID: 17548671891 , 分类ID: 13737800
规格ID: 20830035859 , 价格: 3
菜名: 鱼皮豆腐 , 菜ID: 17548672915 , 分类ID: 13737800
规格ID: 20830036883 , 价格: 3
菜名: 深海鱼蛋丸 , 菜ID: 200000176114181011 , 分类ID: 13737800
规格ID: 200000202122663827 , 价格: 4
菜名: 墨鱼丸 , 菜ID: 17548674963 , 分类ID: 13737800
规格ID: 20830038931 , 价格: 4.5
菜名: 包心贡丸 , 菜ID: 17548675987 , 分类ID: 13737800
规格ID: 20830039955 , 价格: 4.5
菜名: 撒尿牛丸 , 菜ID: 17548677011 , 分类ID: 13737800
规格ID: 20830040979 , 价格: 4.5
菜名: 龙虾丸 , 菜ID: 17548678035 , 分类ID: 13737800
规格ID: 20830042003 , 价格: 4.5
菜名: 北极翅 , 菜ID: 17548680083 , 分类ID: 13737800
规格ID: 20830044051 , 价格: 4
菜名: 玉米肠 , 菜ID: 17548682131 , 分类ID: 13737800
规格ID: 20830046099 , 价格: 4
菜名: 开花肠 , 菜ID: 17548683155 , 分类ID: 13737800
规格ID: 20830047123 , 价格: 3.5
菜名: 亲亲肠 , 菜ID: 17548684179 , 分类ID: 13737800
规格ID: 20830048147 , 价格: 3.5
菜名: 大红肠 , 菜ID: 17548686227 , 分类ID: 13737800
规格ID: 20830050195 , 价格: 4
分类名: 蔬菜菌类
菜名: 土豆 , 菜ID: 17548693395 , 分类ID: 13737835
规格ID: 20830057363 , 价格: 2.5
菜名: 冬瓜 , 菜ID: 17548694419 , 分类ID: 13737835
规格ID: 20830058387 , 价格: 2.5
菜名: 藕片 , 菜ID: 17548695443 , 分类ID: 13737835
规格ID: 20830059411 , 价格: 3
菜名: 莴笋 , 菜ID: 17548696467 , 分类ID: 13737835
规格ID: 20830060435 , 价格: 3
菜名: 白萝卜 , 菜ID: 17548697491 , 分类ID: 13737835
规格ID: 20830061459 , 价格: 2
菜名: 生菜 , 菜ID: 17548699539 , 分类ID: 13737835
规格ID: 20830063507 , 价格: 2.5
菜名: 茼蒿菜 , 菜ID: 17548700563 , 分类ID: 13737835
规格ID: 20830064531 , 价格: 3
菜名: 香菜 , 菜ID: 17548701587 , 分类ID: 13737835
规格ID: 20830065555 , 价格: 3
菜名: 菠菜 , 菜ID: 17548702611 , 分类ID: 13737835
规格ID: 20830066579 , 价格: 3
菜名: 油麦菜 , 菜ID: 17548703635 , 分类ID: 13737835
规格ID: 20830067603 , 价格: 2.5
菜名: 小青菜 , 菜ID: 17548705683 , 分类ID: 13737835
规格ID: 20830069651 , 价格: 2.5
菜名: 娃娃菜 , 菜ID: 17548706707 , 分类ID: 13737835
规格ID: 20830070675 , 价格: 3
菜名: 有机花菜 , 菜ID: 17548707731 , 分类ID: 13737835
规格ID: 20830071699 , 价格: 3.5
菜名: 西兰花 , 菜ID: 17548708755 , 分类ID: 13737835
规格ID: 20830072723 , 价格: 3.5
菜名: 西红柿 , 菜ID: 17548709779 , 分类ID: 13737835
规格ID: 20830073747 , 价格: 3
菜名: 海带结 , 菜ID: 17548710803 , 分类ID: 13737835
规格ID: 20830074771 , 价格: 2.5
菜名: 金针菇 , 菜ID: 17548711827 , 分类ID: 13737835
规格ID: 20830075795 , 价格: 3
菜名: 香菇 , 菜ID: 17548712851 , 分类ID: 13737835
规格ID: 20830076819 , 价格: 3
菜名: 秀珍菇 , 菜ID: 17548713875 , 分类ID: 13737835
规格ID: 20830077843 , 价格: 3
菜名: 海鲜菇 , 菜ID: 17548714899 , 分类ID: 13737835
规格ID: 20830078867 , 价格: 3.5
菜名: 黑木耳 , 菜ID: 17548715923 , 分类ID: 13737835
规格ID: 20830079891 , 价格: 3
菜名: 红薯 , 菜ID: 17548717971 , 分类ID: 13737835
规格ID: 20830081939 , 价格: 2.5
菜名: 特级笋尖/水笋 , 菜ID: 17548718995 , 分类ID: 13737835
规格ID: 20830082963 , 价格: 4
分类名: 豆蛋类
菜名: 油豆腐 , 菜ID: 17548716947 , 分类ID: 13737840
规格ID: 20830080915 , 价格: 3
菜名: 日本豆腐 , 菜ID: 17548721043 , 分类ID: 13737840
规格ID: 20830085011 , 价格: 3
菜名: 绿豆芽 , 菜ID: 17548722067 , 分类ID: 13737840
规格ID: 20830086035 , 价格: 2
菜名: 豆腐皮 , 菜ID: 17548723091 , 分类ID: 13737840
规格ID: 20830087059 , 价格: 2.5
菜名: 厚百叶 , 菜ID: 17548724115 , 分类ID: 13737840
规格ID: 20830088083 , 价格: 3
菜名: 腐竹 , 菜ID: 17548725139 , 分类ID: 13737840
规格ID: 20830089107 , 价格: 3
菜名: 鸭血 , 菜ID: 17548726163 , 分类ID: 13737840
规格ID: 20830090131 , 价格: 3
菜名: 鹌鹑蛋 , 菜ID: 17548727187 , 分类ID: 13737840
规格ID: 20830091155 , 价格: 2.5
菜名: 油面筋 , 菜ID: 17548728211 , 分类ID: 13737840
规格ID: 20830092179 , 价格: 2.5
菜名: 油条 , 菜ID: 17548729235 , 分类ID: 13737840
规格ID: 20830093203 , 价格: 2.5
分类名: 主食类
菜名: 锅巴 , 菜ID: 17548730259 , 分类ID: 13737847
规格ID: 20830094227 , 价格: 2.5
菜名: 方便面 , 菜ID: 17548731283 , 分类ID: 13737847
规格ID: 20830095251 , 价格: 3
菜名: 鸡蛋面 , 菜ID: 17548732307 , 分类ID: 13737847
规格ID: 20830096275 , 价格: 2.5
菜名: 红薯宽粉 , 菜ID: 17548733331 , 分类ID: 13737847
规格ID: 20830097299 , 价格: 3
菜名: 红薯细粉 , 菜ID: 17548734355 , 分类ID: 13737847
规格ID: 20830098323 , 价格: 3
菜名: 蒙古宽粉 , 菜ID: 17548735379 , 分类ID: 13737847
规格ID: 20830099347 , 价格: 3
菜名: 手工细面 , 菜ID: 17548736403 , 分类ID: 13737847
规格ID: 20830100371 , 价格: 2.5
菜名: 刀削面 , 菜ID: 17548737427 , 分类ID: 13737847
规格ID: 20830101395 , 价格: 3
菜名: 玉米面条 , 菜ID: 17548738451 , 分类ID: 13737847
规格ID: 20830102419 , 价格: 4
菜名: 魔芋丝结 , 菜ID: 17548739475 , 分类ID: 13737847
规格ID: 20830103443 , 价格: 5
菜名: 龙口粉丝 , 菜ID: 17548740499 , 分类ID: 13737847
规格ID: 20830104467 , 价格: 4
菜名: 年糕节 , 菜ID: 17548741523 , 分类ID: 13737847
规格ID: 20830105491 , 价格: 2
分类名: 饿了么送红包
菜名: 扫码领红包 , 菜ID: 260439795603 , 分类ID: 526021154
规格ID: 301159743379 , 价格: 0.01
分类名: 霸道总裁套餐
菜名: 招牌霸道~经典荤素~套餐 , 菜ID: 200000173605996435 , 分类ID: 1238754176
规格ID: 200000199013771155 , 价格: 29.4
菜名: 招牌霸道~素食主义~套餐 , 菜ID: 200000173616109459 , 分类ID: 1238754176
规格ID: 200000199009531795 , 价格: 25.2

二、抓取博客园某园友的首页文章列表

以我自己的博客为例:

from urllib import request
import random
from bs4 import BeautifulSoup url = "http://yjmyzz.cnblogs.com/" # 多搞几个user-agent 看上去更真实点~_^
user_agents = [
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36 QQBrowser/4.3.4986.400',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:59.0) Gecko/20100101 Firefox/59.0'] random_user_agent = user_agents[random.randint(0, len(user_agents) - 1)]
page = request.Request(url, headers={'User-Agent': random_user_agent})
html = request.urlopen(page).read().decode("utf-8") bsObj = BeautifulSoup(html, "lxml") # 找出标题的a链接
title_links = bsObj.find_all("a", {"class": "postTitle2"}) with open("blog.csv", "a", encoding='utf-8') as f:
i = 0
for link in title_links:
i += 1
print(str(i), "\t", link.string, "\t", link["href"])
# 保存到csv文件中
f.write(str(i) + "\t" + link.string + "\t" + link["href"] + "\n")

注:BeautifulSoup是一个专门的解析html/xml的模块,贼好用。

输出如下:

1 	 [置顶]关于博客的背景音乐 	 http://www.cnblogs.com/yjmyzz/p/listen-to-your-heart.html
2 python: 序列化/反序列化及对象的深拷贝/浅拷贝 http://www.cnblogs.com/yjmyzz/p/python-serialization-and-object-copy.html
3 python中的zip、lambda、map操作 http://www.cnblogs.com/yjmyzz/p/python-zip-lambda-map.html
4 python面向对象笔记 http://www.cnblogs.com/yjmyzz/p/python-object-oriented-programming.html
5 RxJava2学习笔记(3) http://www.cnblogs.com/yjmyzz/p/rx-java-2-tutorial-3.html
6 RxJava2学习笔记(2) http://www.cnblogs.com/yjmyzz/p/rx-java-2-tutorial-2.html
7 RxJava2学习笔记(1) http://www.cnblogs.com/yjmyzz/p/rx-java-2-tutorial-1.html
8 Matplotlib新手上路(下) http://www.cnblogs.com/yjmyzz/p/matplotlib-tutorial-3.html
9 Matplotlib新手上路(中) http://www.cnblogs.com/yjmyzz/p/matplotlib-tutorial-2.html
10 Matplotlib新手上路(上) http://www.cnblogs.com/yjmyzz/p/matplotlib-tutorial-1.html
11 pycharm如何设置python版本、设置国内pip镜像、添加第三方类库 http://www.cnblogs.com/yjmyzz/p/pycharm-add-third-package-and-add-domestic-mirror.html
12 利用java8对设计模式的重构 http://www.cnblogs.com/yjmyzz/p/refactor-design-pattern-using-java8.html
13 机器学习笔记(6):多类逻辑回归-使用gluon http://www.cnblogs.com/yjmyzz/p/8128122.html
14 spring cloud:Edgware.RELEASE版本hystrix超时新坑 http://www.cnblogs.com/yjmyzz/p/8097713.html
15 spring cloud:Edgware.RELEASE版本中zuul回退方法的变化 http://www.cnblogs.com/yjmyzz/p/8093462.html
16 spring cloud:config-server中@RefreshScope的"陷阱" http://www.cnblogs.com/yjmyzz/p/8085530.html
17 机器学习笔记(5):多类逻辑回归-手动添加隐藏层 http://www.cnblogs.com/yjmyzz/p/8035041.html
18 机器学习笔记(4):多类逻辑回归-使用gluton http://www.cnblogs.com/yjmyzz/p/8034597.html
19 spring boot + embed tomcat + standalone jar的内存泄露问题 http://www.cnblogs.com/yjmyzz/p/the-memory-leak-problem-of-spring-boot-with-embed-tomcat.html
20 机器学习笔记(3):多类逻辑回归 http://www.cnblogs.com/yjmyzz/p/7789252.html
21 归一化(softmax)、信息熵、交叉熵 http://www.cnblogs.com/yjmyzz/p/7822990.html
22 NDArray自动求导 http://www.cnblogs.com/yjmyzz/p/7783286.html
23 机器学习笔记(2):线性回归-使用gluon http://www.cnblogs.com/yjmyzz/p/7774166.html
24 机器学习笔记(1):线性回归 http://www.cnblogs.com/yjmyzz/p/7764496.html
25 mxnet安装及NDArray初体验 http://www.cnblogs.com/yjmyzz/p/mxnet-install-and-ndarray-demo.html
26 jupyter notebook 在mac OS上的安装 http://www.cnblogs.com/yjmyzz/p/how-to-install-jupyter-notebook-on-mac.html
27 spring cloud 学习(11) - 用fastson替换jackson及用gb2312码输出 http://www.cnblogs.com/yjmyzz/p/spring-cloud-set-response-gbk-encoding.html
28 spring cloud 学习(10) - 利用springfox集成swagger http://www.cnblogs.com/yjmyzz/p/how-to-integrate-swagger-with-spring-cloud-by-springfox.html
29 spring-boot 速成(12) - 如何注入多个redis StringRedisTemplate http://www.cnblogs.com/yjmyzz/p/how-to-inject-multi-redis-instance-in-spring-boot.html
30 spring cloud 学习(9) - turbine stream无法在eureka注册的解决办法 http://www.cnblogs.com/yjmyzz/p/spring-cloud-turbine-eureka-register-problem.html
31 java:线上问题排查常用手段 http://www.cnblogs.com/yjmyzz/p/7478266.html
32 java一些常用并发工具示例 http://www.cnblogs.com/yjmyzz/p/java-concurrent-tools-sample.html
33 kafka集群部署 http://www.cnblogs.com/yjmyzz/p/kafka-cluster-deployment.html
34 spring cloud 学习(8) - sleuth & zipkin 调用链跟踪 http://www.cnblogs.com/yjmyzz/p/spring-cloud-with-zipkin.html
35 spring集成kafka http://www.cnblogs.com/yjmyzz/p/spring-integration-with-kafka.html
36 @Transactional导致AbstractRoutingDataSource动态数据源无法切换的解决办法 http://www.cnblogs.com/yjmyzz/p/7390331.html
37 centos上安装elasticsearch 5.5.1 遇到的各种坑 http://www.cnblogs.com/yjmyzz/p/7372561.html
38 spring cloud 学习(7) - 生产环境如何不停机热发布? http://www.cnblogs.com/yjmyzz/p/how-to-hot-release-using-eureka-rest-operation.html
39 spring-boot 速成(11) - 单元测试 http://www.cnblogs.com/yjmyzz/p/unit-test-with-spring-boot.html
40 spring-boot 速成(10) -【个人邮箱/企业邮箱】发送邮件 http://www.cnblogs.com/yjmyzz/p/send-mail-using-spring-boot.html
41 spring cloud 学习(6) - zuul 微服务网关 http://www.cnblogs.com/yjmyzz/p/spring-cloud-zuul-demo.html

csv文件打开截图:

参考文档:

http://beautifulsoup.readthedocs.io/zh_CN/v4.4.0/

python:爬虫入门的更多相关文章

  1. Python爬虫入门一之综述

    大家好哈,最近博主在学习Python,学习期间也遇到一些问题,获得了一些经验,在此将自己的学习系统地整理下来,如果大家有兴趣学习爬虫的话,可以将这些文章作为参考,也欢迎大家一共分享学习经验. Pyth ...

  2. python爬虫入门-开发环境与小例子

    python爬虫入门 开发环境 ubuntu 16.04 sublime pycharm requests库 requests库安装: sudo pip install requests 第一个例子 ...

  3. Python爬虫入门教程 48-100 使用mitmdump抓取手机惠农APP-手机APP爬虫部分

    1. 爬取前的分析 mitmdump是mitmproxy的命令行接口,比Fiddler.Charles等工具方便的地方是它可以对接Python脚本. 有了它我们可以不用手动截获和分析HTTP请求和响应 ...

  4. Python爬虫入门教程 43-100 百思不得姐APP数据-手机APP爬虫部分

    1. Python爬虫入门教程 爬取背景 2019年1月10日深夜,打开了百思不得姐APP,想了一下是否可以爬呢?不自觉的安装到了夜神模拟器里面.这个APP还是比较有名和有意思的. 下面是百思不得姐的 ...

  5. Python 爬虫入门(二)——爬取妹子图

    Python 爬虫入门 听说你写代码没动力?本文就给你动力,爬取妹子图.如果这也没动力那就没救了. GitHub 地址: https://github.com/injetlee/Python/blob ...

  6. Python爬虫入门之正则表达式

    在前面我们已经搞定了怎样获取页面的内容,不过还差一步,这么多杂乱的代码夹杂文字我们怎样把它提取出来整理呢?下面就开始介绍一个十分强大的工具,正则表达式! 1.了解正则表达式 正则表达式是对字符串操作的 ...

  7. Python爬虫入门之Cookie的使用

    本节我们一起来看一下Cookie的使用. 为什么要使用Cookie呢? Cookie,指某些网站为了辨别用户身份.进行session跟踪而储存在用户本地终端上的数据(通常经过加密) 比如说有些网站需要 ...

  8. Python爬虫入门之Urllib库的高级用法

    1.设置Headers 有些网站不会同意程序直接用上面的方式进行访问,如果识别有问题,那么站点根本不会响应,所以为了完全模拟浏览器的工作,我们需要设置一些Headers 的属性. 首先,打开我们的浏览 ...

  9. Python爬虫入门之Urllib库的基本使用

    那么接下来,小伙伴们就一起和我真正迈向我们的爬虫之路吧. 1.分分钟扒一个网页下来 怎样扒网页呢?其实就是根据URL来获取它的网页信息,虽然我们在浏览器中看到的是一幅幅优美的画面,但是其实是由浏览器解 ...

  10. 3.Python爬虫入门三之Urllib和Urllib2库的基本使用

    1.分分钟扒一个网页下来 怎样扒网页呢?其实就是根据URL来获取它的网页信息,虽然我们在浏览器中看到的是一幅幅优美的画面,但是其实是由浏览器解释才呈现出来的,实质它是一段HTML代码,加 JS.CSS ...

随机推荐

  1. 使用apache和nginx代理实现tomcat负载均衡及集群配置详解

    实验环境: 1.nginx的代理功能 nginx proxy: eth0: 192.168.8.48 vmnet2 eth1: 192.168.10.10 tomcat server1: vmnet2 ...

  2. JetBrains 授权服务器(License Server URLS)

    分享几个已经部署好的在线验证服务器:http://idea.iteblog.com/key.php http://idea.imsxm.com/ http://103.207.69.64:1017 h ...

  3. 性能测试三十四:jvm内存结构(栈、堆、永久代)

    Java内存管理机制 Java采用了自动管理内存的方式Java程序是运行在Jvm之中的Java的跨平台的基于Jvm的跨平台特性内存的分配和对象的创建是在Jvm中用户可以通过一系列参数来配置Jvm Jv ...

  4. python简单笔记

    Remarks:python中注意缩进(Tab键或者4个空格) print(输出) 格式:print(values) 字符串.数字.变量等都可以输出: 实例: print(1)->1 print ...

  5. oracle分区表彻底删除的办法,处理删不掉的不规则表名

    Oracle分区表彻底删除的办法当对一个不再使用的分区表进行drop后,查询user_tab_partitions视图发现出现如下不规则的分区表表名:SQL> select distinct t ...

  6. Javascript面向对象基础(二)

    一: 用定义函数的方式定义类在面向对象的思想中,最核心的概念之一就是类.一个类表示了具有相似性质的一类事物的抽象,通过实例化一个类,可以获得属于该类的一个实例,即对象.在JavaScript中定义一个 ...

  7. 【C++ Primer 第11章】4. 无序容器

    一.介绍 1. Hashtable和bucket 由于unordered_map内部采用的hashtable的数据结构存储,所以,每个特定的key会通过一些特定的哈希运算映射到一个特定的位置,我们知道 ...

  8. 微信支付支付宝支付生成二维码的方法(php生成二维码的三种方法)

    如果图简单,可以用在线生成 http://pan.baidu.com/share/qrcode?w=150&h=150&url=http://www.xinzhenkj.com 最简单 ...

  9. Spring的控制反转和依赖注入

    Spring的官网:https://spring.io/ Struts与Hibernate可以做什么事? Struts, Mvc中控制层解决方案 可以进行请求数据自动封装.类型转换.文件上传.效验… ...

  10. Hibernate的主配置文件hibernate.cfg.xml

    1:Hibernate的主配置文件的名字必须是hibernate.cfg.xml(主要配置文件中主要配置:数据库连接信息,其他参数,映射信息):常用配置查看源码:Hibernate\hibernate ...