├── .gitignore ├── Beautiful Soup 爬虫 ├── 001.py ├── 002.py ├── 003.py ├── baidutieba.py ├── bocai.py ├── demo.html ├── dianying.py ├── kouhong.py ├── myiron.py ├── parse_station.py ├── qiubai.py ├── stations.py ├── trainticket.py ├── xiaoshuopaihang.py ├── yueyintai.py ├── 反爬虫.py ├── 沪铜数据.py └── 贴吧帖子结构分析.html ├── Google-Image └── spider.py ├── README.md ├── Scrapy 爬虫框架 ├── 001.py ├── biquge │ ├── biquge │ │ ├── __init__.py │ │ ├── items.py │ │ ├── middlewares.py │ │ ├── pipelines.py │ │ ├── settings.py │ │ └── spiders │ │ │ ├── __init__.py │ │ │ ├── sjzh.py │ │ │ └── xsphspider.py │ └── scrapy.cfg ├── demo.xml ├── mzitu │ ├── mzitu │ │ ├── __init__.py │ │ ├── items.py │ │ ├── middlewares.py │ │ ├── pipelines.py │ │ ├── settings.py │ │ └── spiders │ │ │ ├── __init__.py │ │ │ └── mezitu.py │ └── scrapy.cfg ├── proxy │ ├── proxy │ │ ├── __init__.py │ │ ├── items.py │ │ ├── middlewares.py │ │ ├── pipelines.py │ │ ├── settings.py │ │ └── spiders │ │ │ ├── __init__.py │ │ │ ├── dxdlspider.py │ │ │ └── kdlspider.py │ └── scrapy.cfg ├── test_proxy.py ├── weather │ ├── scrapy.cfg │ └── weather │ │ ├── __init__.py │ │ ├── data │ │ └── weather.json │ │ ├── items.py │ │ ├── middlewares.py │ │ ├── pipelines.py │ │ ├── settings.py │ │ └── spiders │ │ ├── SZtianqi.py │ │ └── __init__.py ├── xiubai │ ├── scrapy.cfg │ └── xiubai │ │ ├── __init__.py │ │ ├── items.py │ │ ├── middlewares.py │ │ ├── middlewares │ │ ├── __init__.py │ │ ├── coustomProxy.py │ │ ├── coustomUserAgent.py │ │ └── proxy.py │ │ ├── pipelines.py │ │ ├── settings.py │ │ └── spiders │ │ ├── __init__.py │ │ └── hotspider.py └── zimuku │ ├── scrapy.cfg │ └── zimuku │ ├── __init__.py │ ├── items.py │ ├── middlewares.py │ ├── pipelines.py │ ├── settings.py │ └── spiders │ ├── __init__.py │ └── demo.py ├── YHShop ├── citydict.py ├── cityid.html ├── handler.py ├── spider.py └── tools.py ├── alipay ├── alipay_v1.py ├── alipay_v2.py └── alipay_v3.py ├── doubanmovie ├── config.py ├── data.py ├── data │ ├── beautifulTop250.json │ ├── cached_douban │ │ ├── 0.html │ │ ├── 100.html │ │ ├── 125.html │ │ ├── 150.html │ │ ├── 175.html │ │ ├── 200.html │ │ ├── 225.html │ │ ├── 25.html │ │ ├── 50.html │ │ └── 75.html │ ├── cached_pansou │ │ ├── 7号房的礼物 .json │ │ ├── E.T. 外星人 .json │ │ ├── V字仇杀队 .json │ │ ├── 一一 .json │ │ ├── 一次别离 .json │ │ ├── 七宗罪 .json │ │ ├── 七武士 .json │ │ ├── 三傻大闹宝莱坞 .json │ │ ├── 上帝之城 .json │ │ ├── 上帝也疯狂 .json │ │ ├── 与狼共舞 .json │ │ ├── 东京物语 .json │ │ ├── 东邪西毒 .json │ │ ├── 两杆大烟枪 .json │ │ ├── 乱世佳人 .json │ │ ├── 二十二 .json │ │ ├── 人工智能 .json │ │ ├── 低俗小说 .json │ │ ├── 侧耳倾听 .json │ │ ├── 借东西的小人阿莉埃蒂 .json │ │ ├── 倩女幽魂 .json │ │ ├── 偷拐抢骗 .json │ │ ├── 傲慢与偏见 .json │ │ ├── 入殓师 .json │ │ ├── 再次出发之纽约遇见你 .json │ │ ├── 冰川时代 .json │ │ ├── 初恋这件小事 .json │ │ ├── 剪刀手爱德华 .json │ │ ├── 加勒比海盗 .json │ │ ├── 勇士 .json │ │ ├── 勇敢的心 .json │ │ ├── 勇闯夺命岛 .json │ │ ├── 十二怒汉 .json │ │ ├── 千与千寻 .json │ │ ├── 千钧一发 .json │ │ ├── 卡萨布兰卡 .json │ │ ├── 卢旺达饭店 .json │ │ ├── 发条橙 .json │ │ ├── 变脸 .json │ │ ├── 叫我第一名 .json │ │ ├── 可可西里 .json │ │ ├── 告白 .json │ │ ├── 哈利·波特与死亡圣器(下) .json │ │ ├── 哈利·波特与魔法石 .json │ │ ├── 哈尔的移动城堡 .json │ │ ├── 哪吒闹海 .json │ │ ├── 唐伯虎点秋香 .json │ │ ├── 喜剧之王 .json │ │ ├── 喜宴 .json │ │ ├── 国王的演讲 .json │ │ ├── 地球上的星星 .json │ │ ├── 城市之光 .json │ │ ├── 夜访吸血鬼 .json │ │ ├── 大卫·戈尔的一生 .json │ │ ├── 大话西游之大圣娶亲 .json │ │ ├── 大话西游之月光宝盒 .json │ │ ├── 大闹天宫 .json │ │ ├── 大鱼 .json │ │ ├── 天使爱美丽 .json │ │ ├── 天堂电影院 .json │ │ ├── 天空之城 .json │ │ ├── 头脑特工队 .json │ │ ├── 完美的世界 .json │ │ ├── 寿司之神 .json │ │ ├── 射雕英雄传之东成西就 .json │ │ ├── 小森林 冬春篇 .json │ │ ├── 小森林 夏秋篇 .json │ │ ├── 小鞋子 .json │ │ ├── 少年派的奇幻漂流 .json │ │ ├── 岁月神偷 .json │ │ ├── 巴黎淘气帮 .json │ │ ├── 布达佩斯大饭店 .json │ │ ├── 幸福终点站 .json │ │ ├── 幽灵公主 .json │ │ ├── 廊桥遗梦 .json │ │ ├── 当幸福来敲门 .json │ │ ├── 彗星来的那一夜 .json │ │ ├── 心灵捕手 .json │ │ ├── 心迷宫 .json │ │ ├── 忠犬八公物语 .json │ │ ├── 忠犬八公的故事 .json │ │ ├── 怦然心动 .json │ │ ├── 怪兽电力公司 .json │ │ ├── 恋恋笔记本 .json │ │ ├── 恐怖游轮 .json │ │ ├── 恐怖直播 .json │ │ ├── 情书 .json │ │ ├── 惊魂记 .json │ │ ├── 我是山姆 .json │ │ ├── 我爱你 .json │ │ ├── 战争之王 .json │ │ ├── 房间 .json │ │ ├── 拯救大兵瑞恩 .json │ │ ├── 指环王1:魔戒再现 .json │ │ ├── 指环王2:双塔奇兵 .json │ │ ├── 指环王3:王者无敌 .json │ │ ├── 控方证人 .json │ │ ├── 搏击俱乐部 .json │ │ ├── 摩登时代 .json │ │ ├── 撞车 .json │ │ ├── 放牛班的春天.json │ │ ├── 放牛班的春天 .json │ │ ├── 教父2 .json │ │ ├── 教父3 .json │ │ ├── 教父 .json │ │ ├── 断背山 .json │ │ ├── 新龙门客栈 .json │ │ ├── 无敌破坏王 .json │ │ ├── 无耻混蛋 .json │ │ ├── 无间道 .json │ │ ├── 时空恋旅人 .json │ │ ├── 星际穿越 .json │ │ ├── 春光乍泄 .json │ │ ├── 暖暖内含光 .json │ │ ├── 曾经 .json │ │ ├── 月球 .json │ │ ├── 朗读者 .json │ │ ├── 未麻的部屋 .json │ │ ├── 末代皇帝 .json │ │ ├── 末路狂花 .json │ │ ├── 本杰明·巴顿奇事 .json │ │ ├── 机器人总动员 .json │ │ ├── 杀人回忆 .json │ │ ├── 枪火 .json │ │ ├── 梦之安魂曲 .json │ │ ├── 楚门的世界 .json │ │ ├── 模仿游戏 .json │ │ ├── 步履不停 .json │ │ ├── 死亡诗社 .json │ │ ├── 沉默的羔羊 .json │ │ ├── 泰坦尼克号 .json │ │ ├── 活着 .json │ │ ├── 浪潮 .json │ │ ├── 海上钢琴师 .json │ │ ├── 海洋 .json │ │ ├── 海盗电台 .json │ │ ├── 海豚湾 .json │ │ ├── 海边的曼彻斯特 .json │ │ ├── 消失的爱人 .json │ │ ├── 源代码 .json │ │ ├── 熔炉 .json │ │ ├── 燃情岁月 .json │ │ ├── 燕尾蝶 .json │ │ ├── 爆裂鼓手 .json │ │ ├── 爱·回家 .json │ │ ├── 爱在午夜降临前 .json │ │ ├── 爱在日落黄昏时 .json │ │ ├── 爱在黎明破晓前 .json │ │ ├── 牯岭街少年杀人事件 .json │ │ ├── 狩猎 .json │ │ ├── 狮子王 .json │ │ ├── 猜火车 .json │ │ ├── 猫鼠游戏 .json │ │ ├── 玛丽和马克思 .json │ │ ├── 玩具总动员3 .json │ │ ├── 甜蜜蜜 .json │ │ ├── 电锯惊魂 .json │ │ ├── 疯狂动物城 .json │ │ ├── 疯狂原始人 .json │ │ ├── 疯狂的石头 .json │ │ ├── 盗梦空间 .json │ │ ├── 看不见的客人 .json │ │ ├── 真爱至上 .json │ │ ├── 碧海蓝天 .json │ │ ├── 神偷奶爸 .json │ │ ├── 禁闭岛 .json │ │ ├── 秒速5厘米 .json │ │ ├── 穆赫兰道 .json │ │ ├── 穿条纹睡衣的男孩 .json │ │ ├── 穿越时空的少女 .json │ │ ├── 窃听风暴 .json │ │ ├── 第六感 .json │ │ ├── 素媛 .json │ │ ├── 红辣椒 .json │ │ ├── 纵横四海 .json │ │ ├── 终结者2:审判日 .json │ │ ├── 绿里奇迹 .json │ │ ├── 罗生门 .json │ │ ├── 罗马假日 .json │ │ ├── 美丽人生 .json │ │ ├── 美丽心灵 .json │ │ ├── 美国丽人 .json │ │ ├── 美国往事 .json │ │ ├── 肖申克的救赎 .json │ │ ├── 致命ID .json │ │ ├── 致命魔术 .json │ │ ├── 花样年华 .json │ │ ├── 英国病人 .json │ │ ├── 英雄本色 .json │ │ ├── 荒岛余生 .json │ │ ├── 荒蛮故事 .json │ │ ├── 荒野生存 .json │ │ ├── 菊次郎的夏天 .json │ │ ├── 萤火之森 .json │ │ ├── 萤火虫之墓 .json │ │ ├── 蓝色大门 .json │ │ ├── 虎口脱险 .json │ │ ├── 蝙蝠侠:黑暗骑士 .json │ │ ├── 蝙蝠侠:黑暗骑士崛起 .json │ │ ├── 蝴蝶 .json │ │ ├── 蝴蝶效应 .json │ │ ├── 血钻 .json │ │ ├── 被嫌弃的松子的一生 .json │ │ ├── 被解救的姜戈 .json │ │ ├── 西西里的美丽传说 .json │ │ ├── 触不可及 .json │ │ ├── 让子弹飞 .json │ │ ├── 记忆碎片 .json │ │ ├── 谍影重重2 .json │ │ ├── 谍影重重3 .json │ │ ├── 谍影重重 .json │ │ ├── 贫民窟的百万富翁 .json │ │ ├── 超能陆战队 .json │ │ ├── 超脱 .json │ │ ├── 辛德勒的名单 .json │ │ ├── 辩护人 .json │ │ ├── 达拉斯买家俱乐部 .json │ │ ├── 迁徙的鸟 .json │ │ ├── 这个杀手不太冷 .json │ │ ├── 这个男人来自地球 .json │ │ ├── 追随 .json │ │ ├── 遗愿清单 .json │ │ ├── 重庆森林 .json │ │ ├── 钢琴家 .json │ │ ├── 闻香识女人 .json │ │ ├── 阳光姐妹淘 .json │ │ ├── 阳光灿烂的日子 .json │ │ ├── 阿凡达 .json │ │ ├── 阿甘正传 .json │ │ ├── 阿飞正传 .json │ │ ├── 雨中曲 .json │ │ ├── 雨人 .json │ │ ├── 霸王别姬 .json │ │ ├── 青蛇 .json │ │ ├── 非常嫌疑犯 .json │ │ ├── 音乐之声 .json │ │ ├── 风之谷 .json │ │ ├── 飞屋环游记 .json │ │ ├── 飞越疯人院 .json │ │ ├── 饮食男女 .json │ │ ├── 香水 .json │ │ ├── 驯龙高手 .json │ │ ├── 鬼子来了 .json │ │ ├── 魂断蓝桥 .json │ │ ├── 魔女宅急便 .json │ │ ├── 麦兜故事 .json │ │ ├── 黄金三镖客 .json │ │ ├── 黑天鹅 .json │ │ ├── 黑客帝国3:矩阵革命 .json │ │ ├── 黑客帝国 .json │ │ └── 龙猫 .json │ ├── doubanTop250.json │ └── 豆瓣电影250.xls ├── doubanspider.py └── panspider.py ├── douyu ├── douyu_danmu.py └── douyu_test.py ├── gamedownload ├── fcspider.py └── readme.md ├── ithome ├── apple.json ├── city_count_res.py ├── config.py ├── datahandleer.py ├── pipeline.py └── spider.py ├── mazhifu ├── config.py ├── readme.md ├── requirements.txt └── spider.py ├── p2p ├── .vscode │ └── launch.json ├── data │ ├── 1.json │ ├── 10.json │ ├── 100.json │ ├── 101.json │ ├── 102.json │ ├── 103.json │ ├── 104.json │ ├── 105.json │ ├── 106.json │ ├── 107.json │ ├── 108.json │ ├── 109.json │ ├── 11.json │ ├── 110.json │ ├── 111.json │ ├── 112.json │ ├── 113.json │ ├── 114.json │ ├── 115.json │ ├── 116.json │ ├── 117.json │ ├── 118.json │ ├── 119.json │ ├── 12.json │ ├── 120.json │ ├── 121.json │ ├── 122.json │ ├── 123.json │ ├── 124.json │ ├── 125.json │ ├── 126.json │ ├── 127.json │ ├── 128.json │ ├── 129.json │ ├── 13.json │ ├── 130.json │ ├── 131.json │ ├── 132.json │ ├── 133.json │ ├── 134.json │ ├── 135.json │ ├── 136.json │ ├── 137.json │ ├── 138.json │ ├── 139.json │ ├── 14.json │ ├── 140.json │ ├── 141.json │ ├── 142.json │ ├── 143.json │ ├── 144.json │ ├── 145.json │ ├── 146.json │ ├── 147.json │ ├── 148.json │ ├── 149.json │ ├── 15.json │ ├── 150.json │ ├── 151.json │ ├── 152.json │ ├── 153.json │ ├── 154.json │ ├── 155.json │ ├── 156.json │ ├── 157.json │ ├── 158.json │ ├── 159.json │ ├── 16.json │ ├── 160.json │ ├── 161.json │ ├── 162.json │ ├── 163.json │ ├── 164.json │ ├── 165.json │ ├── 166.json │ ├── 167.json │ ├── 168.json │ ├── 169.json │ ├── 17.json │ ├── 170.json │ ├── 171.json │ ├── 172.json │ ├── 173.json │ ├── 174.json │ ├── 175.json │ ├── 176.json │ ├── 177.json │ ├── 178.json │ ├── 179.json │ ├── 18.json │ ├── 180.json │ ├── 181.json │ ├── 182.json │ ├── 183.json │ ├── 184.json │ ├── 185.json │ ├── 186.json │ ├── 187.json │ ├── 188.json │ ├── 189.json │ ├── 19.json │ ├── 190.json │ ├── 191.json │ ├── 192.json │ ├── 193.json │ ├── 194.json │ ├── 195.json │ ├── 196.json │ ├── 197.json │ ├── 198.json │ ├── 199.json │ ├── 2.json │ ├── 20.json │ ├── 200.json │ ├── 201.json │ ├── 202.json │ ├── 203.json │ ├── 204.json │ ├── 205.json │ ├── 206.json │ ├── 207.json │ ├── 208.json │ ├── 209.json │ ├── 21.json │ ├── 210.json │ ├── 211.json │ ├── 212.json │ ├── 213.json │ ├── 214.json │ ├── 215.json │ ├── 216.json │ ├── 217.json │ ├── 218.json │ ├── 219.json │ ├── 22.json │ ├── 220.json │ ├── 221.json │ ├── 222.json │ ├── 23.json │ ├── 24.json │ ├── 25.json │ ├── 26.json │ ├── 27.json │ ├── 28.json │ ├── 29.json │ ├── 3.json │ ├── 30.json │ ├── 31.json │ ├── 32.json │ ├── 33.json │ ├── 34.json │ ├── 35.json │ ├── 36.json │ ├── 37.json │ ├── 38.json │ ├── 39.json │ ├── 4.json │ ├── 40.json │ ├── 41.json │ ├── 42.json │ ├── 43.json │ ├── 44.json │ ├── 45.json │ ├── 46.json │ ├── 47.json │ ├── 48.json │ ├── 49.json │ ├── 5.json │ ├── 50.json │ ├── 51.json │ ├── 52.json │ ├── 53.json │ ├── 54.json │ ├── 55.json │ ├── 56.json │ ├── 57.json │ ├── 58.json │ ├── 59.json │ ├── 6.json │ ├── 60.json │ ├── 61.json │ ├── 62.json │ ├── 63.json │ ├── 64.json │ ├── 65.json │ ├── 66.json │ ├── 67.json │ ├── 68.json │ ├── 69.json │ ├── 7.json │ ├── 70.json │ ├── 71.json │ ├── 72.json │ ├── 73.json │ ├── 74.json │ ├── 75.json │ ├── 76.json │ ├── 77.json │ ├── 78.json │ ├── 79.json │ ├── 8.json │ ├── 80.json │ ├── 81.json │ ├── 82.json │ ├── 83.json │ ├── 84.json │ ├── 85.json │ ├── 86.json │ ├── 87.json │ ├── 88.json │ ├── 89.json │ ├── 9.json │ ├── 90.json │ ├── 91.json │ ├── 92.json │ ├── 93.json │ ├── 94.json │ ├── 95.json │ ├── 96.json │ ├── 97.json │ ├── 98.json │ └── 99.json ├── json │ ├── 1.json │ ├── 10.json │ ├── 100.json │ ├── 101.json │ ├── 102.json │ ├── 103.json │ ├── 104.json │ ├── 105.json │ ├── 106.json │ ├── 107.json │ ├── 108.json │ ├── 109.json │ ├── 11.json │ ├── 110.json │ ├── 111.json │ ├── 112.json │ ├── 113.json │ ├── 114.json │ ├── 115.json │ ├── 116.json │ ├── 117.json │ ├── 118.json │ ├── 119.json │ ├── 12.json │ ├── 120.json │ ├── 121.json │ ├── 122.json │ ├── 123.json │ ├── 124.json │ ├── 125.json │ ├── 126.json │ ├── 127.json │ ├── 128.json │ ├── 129.json │ ├── 13.json │ ├── 130.json │ ├── 131.json │ ├── 132.json │ ├── 133.json │ ├── 134.json │ ├── 135.json │ ├── 136.json │ ├── 137.json │ ├── 138.json │ ├── 139.json │ ├── 14.json │ ├── 140.json │ ├── 141.json │ ├── 142.json │ ├── 143.json │ ├── 144.json │ ├── 145.json │ ├── 146.json │ ├── 147.json │ ├── 148.json │ ├── 149.json │ ├── 15.json │ ├── 150.json │ ├── 151.json │ ├── 152.json │ ├── 153.json │ ├── 154.json │ ├── 155.json │ ├── 156.json │ ├── 157.json │ ├── 158.json │ ├── 159.json │ ├── 16.json │ ├── 160.json │ ├── 161.json │ ├── 162.json │ ├── 163.json │ ├── 164.json │ ├── 165.json │ ├── 166.json │ ├── 167.json │ ├── 168.json │ ├── 169.json │ ├── 17.json │ ├── 170.json │ ├── 171.json │ ├── 172.json │ ├── 173.json │ ├── 174.json │ ├── 175.json │ ├── 176.json │ ├── 177.json │ ├── 178.json │ ├── 179.json │ ├── 18.json │ ├── 180.json │ ├── 181.json │ ├── 182.json │ ├── 183.json │ ├── 184.json │ ├── 185.json │ ├── 186.json │ ├── 187.json │ ├── 188.json │ ├── 189.json │ ├── 19.json │ ├── 190.json │ ├── 191.json │ ├── 192.json │ ├── 193.json │ ├── 194.json │ ├── 195.json │ ├── 196.json │ ├── 197.json │ ├── 198.json │ ├── 199.json │ ├── 2.json │ ├── 20.json │ ├── 200.json │ ├── 201.json │ ├── 202.json │ ├── 203.json │ ├── 204.json │ ├── 205.json │ ├── 206.json │ ├── 207.json │ ├── 208.json │ ├── 209.json │ ├── 21.json │ ├── 210.json │ ├── 211.json │ ├── 212.json │ ├── 213.json │ ├── 214.json │ ├── 215.json │ ├── 216.json │ ├── 217.json │ ├── 218.json │ ├── 219.json │ ├── 22.json │ ├── 220.json │ ├── 221.json │ ├── 222.json │ ├── 23.json │ ├── 24.json │ ├── 25.json │ ├── 26.json │ ├── 27.json │ ├── 28.json │ ├── 29.json │ ├── 3.json │ ├── 30.json │ ├── 31.json │ ├── 32.json │ ├── 33.json │ ├── 34.json │ ├── 35.json │ ├── 36.json │ ├── 37.json │ ├── 38.json │ ├── 39.json │ ├── 4.json │ ├── 40.json │ ├── 41.json │ ├── 42.json │ ├── 43.json │ ├── 44.json │ ├── 45.json │ ├── 46.json │ ├── 47.json │ ├── 48.json │ ├── 49.json │ ├── 5.json │ ├── 50.json │ ├── 51.json │ ├── 52.json │ ├── 53.json │ ├── 54.json │ ├── 55.json │ ├── 56.json │ ├── 57.json │ ├── 58.json │ ├── 59.json │ ├── 6.json │ ├── 60.json │ ├── 61.json │ ├── 62.json │ ├── 63.json │ ├── 64.json │ ├── 65.json │ ├── 66.json │ ├── 67.json │ ├── 68.json │ ├── 69.json │ ├── 7.json │ ├── 70.json │ ├── 71.json │ ├── 72.json │ ├── 73.json │ ├── 74.json │ ├── 75.json │ ├── 76.json │ ├── 77.json │ ├── 78.json │ ├── 79.json │ ├── 8.json │ ├── 80.json │ ├── 81.json │ ├── 82.json │ ├── 83.json │ ├── 84.json │ ├── 85.json │ ├── 86.json │ ├── 87.json │ ├── 88.json │ ├── 89.json │ ├── 9.json │ ├── 90.json │ ├── 91.json │ ├── 92.json │ ├── 93.json │ ├── 94.json │ ├── 95.json │ ├── 96.json │ ├── 97.json │ ├── 98.json │ └── 99.json └── p2p_spider.py ├── requestes基本使用 ├── 001.py ├── 002.py ├── login.py └── test.py ├── sougou ├── configs.py ├── jiebao.py ├── spider │ ├── log_SougouDownloader.log.20171118 │ ├── log_SougouSpider.log.20171118 │ └── spider.py ├── store_new │ ├── __init__.py │ └── stroe.py └── utils │ ├── __init__.py │ └── tools.py ├── toapi-91baby ├── .gitignore ├── app.py ├── data.sqlite ├── items │ ├── __init__.py │ ├── book.py │ ├── hotbook.py │ └── search.py ├── settings.py ├── test.py └── wsgi.py ├── wenjuanxin ├── configs.py └── spider.py ├── zhihu └── zhihu_easy │ ├── __init__.py │ ├── client.py │ ├── configs.py │ ├── db_tools.py │ ├── parse.py │ ├── playdata.py │ ├── spider.py │ └── tools.py ├── 悦美整形 └── spider.py ├── 浏览器模拟爬虫 ├── 001.py ├── baidu.py ├── kuaiproxy.py ├── manhua.py └── manhua_mutiprocessing.py ├── 美食杰 └── spider.py ├── 腾讯漫画 ├── 632784.json ├── downloder.py ├── one.json └── spider.py └── 豆瓣影评 └── 锤神3 ├── config.py ├── play_data.py ├── spider.py └── stroe.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | local_settings.py 55 | 56 | # Flask stuff: 57 | instance/ 58 | .webassets-cache 59 | 60 | # Scrapy stuff: 61 | .scrapy 62 | 63 | # Sphinx documentation 64 | docs/_build/ 65 | 66 | # PyBuilder 67 | target/ 68 | 69 | # IPython Notebook 70 | .ipynb_checkpoints 71 | 72 | # pyenv 73 | .python-version 74 | 75 | # celery beat schedule file 76 | celerybeat-schedule 77 | 78 | # dotenv 79 | .env 80 | 81 | # virtualenv 82 | venv/ 83 | ENV/ 84 | 85 | # Spyder project settings 86 | .spyderproject 87 | 88 | # Rope project settings 89 | .ropeproject 90 | 91 | # mac 92 | .DS_Store 93 | 94 | # vs code 95 | settings.json 96 | -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/001.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 通过一些小例子来了解bs4库的基本使用, 3 | 本篇为lxml解析器的使用 4 | 解析的html为当前目录下的demo.html 5 | ''' 6 | import bs4 7 | 8 | 9 | #首先我们先将html文件已lxml的方式做成一锅汤 10 | soup = bs4.BeautifulSoup(open('Beautiful Soup 爬虫/demo.html'),'lxml') 11 | 12 | #我们把结果输出一下,是一个很清晰的树形结构。 13 | #print(soup.prettify()) 14 | 15 | ''' 16 | OUT: 17 | 18 | 19 |
20 |26 | 27 | The Dormouse's story 28 | 29 |
30 |31 | Once upon a time there were three little sisters; and their names were 32 | 33 | Elsie 34 | 35 | , 36 | 37 | Lacie 38 | 39 | and 40 | 41 | Tillie 42 | 43 | ; 44 | and they lived at the bottom of a well. 45 |
46 |47 | ... 48 |
49 | 50 | 51 | ''' -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/002.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 简单的bs4库的使用 3 | ''' 4 | 5 | import bs4 6 | 7 | 8 | #首先我们先将html文件已lxml的方式做成一锅汤 9 | soup = bs4.BeautifulSoup(open('Beautiful Soup 爬虫/demo.html'),'lxml') 10 | 11 | #找到head标签里的内容 12 | #print (soup.head) 13 | 14 | #找到所有的text内容 15 | #print (soup.text) 16 | 17 | #找到第一个a标签 18 | #print (soup.a) 19 | 20 | #找到所有a标签 21 | #print (soup.find_all('a')) 22 | 23 | #找到a标签下的所有子节点,一列表方式返回 24 | #print(soup.a.contents) 25 | 26 | #通过.children生成器,我们可以循环迭代出每一个子节点 27 | #tag = soup.body 28 | #for s in tag.children: 29 | # print(s) 30 | 31 | #通过迭代找到所的string 32 | for i in soup.strings: 33 | print(i) -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/003.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 通过Python来学习re库 --- 正则表达式相关内容 3 | 4 | ''' 5 | 6 | import re 7 | 8 | test = 'python is the best language , pretty good !' 9 | 10 | p = re.findall('p+',test) 11 | 12 | print(p) 13 | 14 | 15 | ''' 16 | re.search(pattern, string, flags=0) 17 | 在一个字符串中搜索匹配正则表达式的第一个位置 18 | 返回match对象 19 | ∙ pattern : 正则表达式的字符串或原生字符串表示 20 | ∙ string : 待匹配字符串 21 | ∙ flags : 正则表达式使用时的控制标记 22 | ''' 23 | 24 | str1 = 'hello , world ,life is short ,use Python .WHAT? ' 25 | 26 | a = re.search(r'\w+',str1) 27 | print(a.group()) # hello 28 | 29 | b = re.search(r'w.+D',str1,re.I) 30 | print(b.group()) 31 | 32 | 33 | ''' 34 | re.findall(pattern, string, flags=0) 35 | 搜索字符串,以列表类型返回全部能匹配的子串 36 | ∙ pattern : 正则表达式的字符串或原生字符串表示 37 | ∙ string : 待匹配字符串 38 | ∙ flags : 正则表达式使用时的控制标记 39 | ''' 40 | 41 | c = re.findall(r'\w+',str1) 42 | print (c) 43 | #['hello', 'world', 'life', 'is', 'short', 'use', 'Python', 'WHAT'] 44 | 45 | str2 = 'hssso' 46 | re1 = re.compile(r'h.{3}o') 47 | print(re1.findall(str1)) 48 | print(re1.findall(str2)) 49 | # ['hello'] 50 | #['hssso'] 51 | 52 | ''' 53 | match 对象的属性 54 | 55 | .string : 待匹配的文本 56 | .re : 匹配时使用的patter对象(正则表达式) 57 | .pos : 正则表达式搜索文本的开始位置 58 | .endpos : 正则表达式搜索文本的结束位置 59 | ''' 60 | d = re.search(r'e.+d',str1) 61 | print(d.group()) # ello , world 62 | print (d.string) # hello , world ,life is short ,use Python .WHAT? 63 | print (d.re) # re.compile('e.+d') 64 | print (d.pos) # 0 65 | print (d.endpos) # 48 66 | -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/baidutieba.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 抓取百度贴吧---生活大爆炸吧的基本内容 3 | 爬虫线路: requests - bs4 4 | Python版本: 3.6 5 | OS: mac os 12.12.4 6 | ''' 7 | 8 | import requests 9 | import time 10 | from bs4 import BeautifulSoup 11 | 12 | # 首先我们写好抓取网页的函数 13 | 14 | 15 | def get_html(url): 16 | try: 17 | r = requests.get(url, timeout=30) 18 | r.raise_for_status() 19 | # 这里我们知道百度贴吧的编码是utf-8,所以手动设置的。爬去其他的页面时建议使用: 20 | # r.encoding = r.apparent_encoding 21 | r.encoding = 'utf-8' 22 | return r.text 23 | except: 24 | return " ERROR " 25 | 26 | 27 | def get_content(url): 28 | ''' 29 | 分析贴吧的网页文件,整理信息,保存在列表变量中 30 | ''' 31 | 32 | # 初始化一个列表来保存所有的帖子信息: 33 | comments = [] 34 | # 首先,我们把需要爬取信息的网页下载到本地 35 | html = get_html(url) 36 | 37 | # 我们来做一锅汤 38 | soup = BeautifulSoup(html, 'lxml') 39 | 40 | # 按照之前的分析,我们找到所有具有‘ j_thread_list clearfix’属性的li标签。返回一个列表类型。 41 | liTags = soup.find_all('li', attrs={'class': ' j_thread_list clearfix'}) 42 | 43 | # 通过循环找到每个帖子里的我们需要的信息: 44 | for li in liTags: 45 | # 初始化一个字典来存储文章信息 46 | comment = {} 47 | # 这里使用一个try except 防止爬虫找不到信息从而停止运行 48 | try: 49 | # 开始筛选信息,并保存到字典中 50 | comment['title'] = li.find( 51 | 'a', attrs={'class': 'j_th_tit '}).text.strip() 52 | comment['last_reply_data'] = li.find('span',attrs={'class':'threadlist_reply_date pull_right j_reply_data'}).text.strip() 53 | comments.append(comment) 54 | except: 55 | print('出了点小问题') 56 | 57 | return comments 58 | 59 | 60 | def Out2File(dict): 61 | ''' 62 | 将爬取到的文件写入到本地 63 | 保存到当前目录的 TTBT.txt文件中。 64 | 65 | ''' 66 | with open('TTBT.txt', 'a+') as f: 67 | for comment in dict: 68 | f.write('标题: {} \t 链接:{} \t 发帖人:{} \t 发帖时间:{} \t 回复数量: {} \n'.format( 69 | comment['title'], comment['last_reply_data'])) 70 | 71 | print('当前页面爬取完成') 72 | 73 | 74 | def main(base_url, deep): 75 | url_list = [] 76 | # 将所有需要爬去的url存入列表 77 | for i in range(0, deep): 78 | url_list.append(base_url + '&pn=' + str(50 * i)) 79 | print('所有的网页已经下载到本地! 开始筛选信息。。。。') 80 | 81 | # 循环写入所有的数据 82 | for url in url_list: 83 | content = get_content(url) 84 | Out2File(content) 85 | print('所有的信息都已经保存完毕!') 86 | 87 | 88 | base_url = 'http://tieba.baidu.com/f?kw=%E7%94%9F%E6%B4%BB%E5%A4%A7%E7%88%86%E7%82%B8&ie=utf-8' 89 | # 设置需要爬取的页码数量 90 | deep = 1 91 | 92 | if __name__ == '__main__': 93 | main(base_url, deep) 94 | -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/bocai.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 爬取Dota菠菜结果信息 3 | 使用 requests --- bs4 线路 4 | Python版本: 3.6 5 | OS: mac os 12.12.4 6 | ''' 7 | 8 | import requests 9 | import bs4 10 | 11 | def get_html(url): 12 | try: 13 | r = requests.get(url, timeout=30) 14 | r.raise_for_status() 15 | r.encoding = r.apparent_encoding 16 | return r.text 17 | except: 18 | return " ERROR " 19 | 20 | def print_result(url): 21 | ''' 22 | 查询比赛结果,并格式化输出! 23 | ''' 24 | html = get_html(url) 25 | soup = bs4.BeautifulSoup(html,'lxml') 26 | match_list = soup.find_all('div', attrs={'class': 'matchmain bisai_qukuai'}) 27 | for match in match_list: 28 | time = match.find('div', attrs={'class': 'whenm'}).text.strip() 29 | teamname = match.find_all('span', attrs={'class': 'team_name'}) 30 | 31 | 32 | #由于网站的构造问题,队名有的时候会不显示,所以我们需要过滤掉一些注释,方法如下: 33 | if teamname[0].string[0:3] == 'php': 34 | team1_name = "暂无队名" 35 | else: 36 | team1_name = teamname[0].string 37 | 38 | # 这里我们采用了css选择器:比原来的属性选择更加方便 39 | team1_support_level = match.find('span', class_='team_number_green').string 40 | 41 | team2_name = teamname[1].string 42 | team2_support_level = match.find('span', class_='team_number_red').string 43 | 44 | print('比赛时间:{},\n 队伍一:{} 胜率 {}\n 队伍二:{} 胜率 {} \n'.format(time,team1_name,team1_support_level,team2_name,team2_support_level)) 45 | 46 | 47 | 48 | def main(): 49 | url= 'http://dota2bocai.com/match' 50 | print_result(url) 51 | 52 | if __name__ == '__main__': 53 | main() -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/demo.html: -------------------------------------------------------------------------------- 1 | 2 |The Dormouse's story
5 | 6 |Once upon a time there were three little sisters; and their names were 7 | Elsie, 8 | Lacie and 9 | Tillie; 10 | and they lived at the bottom of a well.
11 | 12 |...
13 | -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/dianying.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 爬取最新电影排行榜单 3 | url:http://dianying.2345.com/top/ 4 | 使用 requests --- bs4 线路 5 | Python版本: 3.6 6 | OS: mac os 12.12.4 7 | ''' 8 | 9 | import requests 10 | import bs4 11 | 12 | 13 | def get_html(url): 14 | try: 15 | r = requests.get(url, timeout=30) 16 | r.raise_for_status 17 | # 该网站采用gbk编码! 18 | r.encoding = 'gbk' 19 | return r.text 20 | except: 21 | return "someting wrong" 22 | 23 | 24 | def get_content(url): 25 | html = get_html(url) 26 | soup = bs4.BeautifulSoup(html, 'lxml') 27 | 28 | # 找到电影排行榜的ul列表 29 | movies_list = soup.find('ul', class_='picList clearfix') 30 | movies = movies_list.find_all('li') 31 | 32 | for top in movies: 33 | #找到图片连接, 34 | img_url=top.find('img')['src'] 35 | 36 | 37 | name = top.find('span',class_='sTit').a.text 38 | #这里做一个异常捕获,防止没有上映时间的出现 39 | try: 40 | time = top.find('span',class_='sIntro').text 41 | except: 42 | time = "暂无上映时间" 43 | 44 | #这里用bs4库迭代找出“pACtor”的所有子孙节点,即每一位演员解决了名字分割的问题 45 | actors = top.find('p',class_='pActor') 46 | actor= '' 47 | for act in actors.contents: 48 | actor = actor + act.string +' ' 49 | #找到影片简介 50 | intro = top.find('p',class_='pTxt pIntroShow').text 51 | 52 | print("片名:{}\t{}\n{}\n{} \n \n ".format(name,time,actor,intro) ) 53 | 54 | #我们来吧图片下载下来: 55 | with open('/Users/ehco/Desktop/img/'+name+'.png','wb+') as f: 56 | f.write(requests.get(img_url).content) 57 | 58 | 59 | def main(): 60 | url = 'http://dianying.2345.com/top/' 61 | get_content(url) 62 | 63 | if __name__ == "__main__": 64 | main() -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/kouhong.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Author Ehco1996 3 | Time 2017-11-10 4 | 5 | 如何暗示男朋友给自己买火红 6 | ''' 7 | 8 | from bs4 import BeautifulSoup 9 | import requests 10 | import os 11 | 12 | 13 | def get_html_text(url): 14 | try: 15 | r = requests.get(url, timeout=10) 16 | r.raise_for_status 17 | return r.text 18 | except: 19 | return -1 20 | 21 | 22 | def parse_img(html): 23 | data = [] 24 | soup = BeautifulSoup(html, 'lxml') 25 | img_list = soup.find_all('img') 26 | for img in img_list: 27 | data.append({ 28 | 'src': img['src'], 29 | 'name': img['alt'].replace(' ', '').replace('/', '') 30 | }) 31 | return data 32 | 33 | 34 | def get_img_response(url): 35 | try: 36 | r = requests.get(url, stream=True) 37 | r.raise_for_status 38 | return r.content 39 | except: 40 | return -1 41 | 42 | 43 | def download_img(data): 44 | curr_dir = os.path.dirname(os.path.realpath(__file__)) + '/img/' 45 | if not os.path.exists('img'): 46 | os.mkdir('img') 47 | for img in data: 48 | path = os.path.join(curr_dir, img['name'] + '.jpg') 49 | with open(path, 'wb') as f: 50 | f.write(get_img_response(img['src'])) 51 | 52 | 53 | def main(): 54 | html = get_html_text( 55 | 'https://www.1688.com/pic/-.html?spm=a261b.8768355.searchbar.5.oUjRZK&keywords=%BF%DA%BA%EC') 56 | if html != -1: 57 | img_data = parse_img(html) 58 | download_img(img_data) 59 | 60 | 61 | if __name__ == '__main__': 62 | main() 63 | -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/parse_station.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import re 3 | 4 | #关闭https证书验证警告 5 | requests.packages.urllib3.disable_warnings() 6 | 7 | url = 'https://kyfw.12306.cn/otn/resources/js/framework/station_name.js?station_version=1.9018' 8 | r = requests.get(url,verify=False) 9 | pattern = u'([\u4e00-\u9fa5]+)\|([A-Z]+)' 10 | result = re.findall(pattern,r.text) 11 | station = dict(result) 12 | 13 | print(station) -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/qiubai.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from bs4 import BeautifulSoup 3 | 4 | 5 | def get_html_text(url): 6 | try: 7 | r = requests.get(url, timeout=3) 8 | r.raise_for_status() 9 | r.encoding = r.apparent_encoding 10 | return r.text 11 | except: 12 | return 'something wrong' 13 | 14 | 15 | def get_jokes(url): 16 | ''' 17 | 返回当前url页面的糗百的 18 | 段子作者,主体,热评 19 | 返回类型:列表 20 | ''' 21 | joke_list = [] 22 | 23 | html = get_html_text(url) 24 | soup = BeautifulSoup(html, 'lxml') 25 | 26 | articles = soup.find_all('div', class_='article block untagged mb15') 27 | 28 | for article in articles: 29 | body = article.find('span').text 30 | author = article.find('img')['alt'] 31 | try: 32 | comment = article.find( 33 | 'div', class_='main-text').contents[0].replace('\n', '') 34 | except: 35 | comment = '暂时没有热评' 36 | 37 | joke = '作者:{}\n{}\n\n热评{}'.format(author, body, comment) 38 | joke_list.append(joke) 39 | 40 | return joke_list 41 | 42 | 43 | # test: 44 | 45 | url = 'https://www.qiushibaike.com/8hr' 46 | 47 | a = get_jokes(url) 48 | print(a[1]) 49 | -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/反爬虫.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import random 3 | 4 | 5 | def get_html(url): 6 | try: 7 | r = requests.get(url, timeout=30) 8 | print(r.headers) 9 | r.raise_for_status 10 | r.encoding = r.apparent_encoding 11 | 12 | return r.status_code 13 | except: 14 | return "Someting Wrong!" 15 | 16 | 17 | def get_agent(): 18 | ''' 19 | 模拟header的user-agent字段, 20 | 返回一个随机的user-agent字典类型的键值对 21 | ''' 22 | agents = ['Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;', 23 | 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv,2.0.1) Gecko/20100101 Firefox/4.0.1', 24 | 'Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11', 25 | 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11', 26 | 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)'] 27 | fakeheader = {} 28 | fakeheader['User-agent'] = agents[random.randint(0, len(agents))] 29 | return fakeheader 30 | 31 | 32 | def get_proxy(): 33 | ''' 34 | 简答模拟代理池 35 | 返回一个字典类型的键值对, 36 | ''' 37 | proxy = ["http://116.211.143.11:80", 38 | "http://183.1.86.235:8118", 39 | "http://183.32.88.244:808", 40 | "http://121.40.42.35:9999", 41 | "http://222.94.148.210:808"] 42 | fakepxs = {} 43 | fakepxs['http'] = proxy[random.randint(0, len(proxy))] 44 | return fakepxs 45 | 46 | 47 | print(get_html('https://zhuanlan.zhihu.com')) -------------------------------------------------------------------------------- /Beautiful Soup 爬虫/沪铜数据.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 获取新浪网 沪铜CUO历史交易记录 3 | 从1999-01-01 到 2017-06-15 4 | 网址:http://vip.stock.finance.sina.com.cn/q/view/vFutures_History.php?page=1&breed=CU0&start=1999-01-01&end=2017-06-15&jys=shfe&pz=CU&hy=CU0&type=inner&name=%A1%E4%A8%AE%26%23182%3B11109 5 | ''' 6 | 7 | import requests 8 | from bs4 import BeautifulSoup 9 | 10 | def get_html_text(url): 11 | try: 12 | r = requests.get(url,timeout=3) 13 | r.raise_for_status() 14 | r.encoding = r.apparent_encoding 15 | return r.text 16 | except: 17 | return 'something wrong' 18 | 19 | 20 | 21 | def get_one_data(url): 22 | data = [] 23 | html = get_html_text(url) 24 | soup = BeautifulSoup(html,'lxml') 25 | days = soup.find('div',class_='historyList') 26 | columns = days.find_all('tr') 27 | 28 | ''' 29 | test area: 30 | info = columns[2].find_all('td') 31 | date = info[0].text 32 | close_price = info[1].text 33 | print(date,close_price) 34 | ''' 35 | 36 | for i in range(2,len(columns)): 37 | try: 38 | info = columns[i].find_all('td') 39 | date = info[0].text 40 | close_price = info[1].text 41 | data.append(date+' : '+close_price) 42 | except: 43 | continue 44 | 45 | return data 46 | 47 | def W2File(data): 48 | with open('cuo_data.txt','a+') as f: 49 | for one in data: 50 | f.write(one+'\n') 51 | 52 | print('数据写入完毕!') 53 | 54 | #url = 'http://vip.stock.finance.sina.com.cn/q/view/vFutures_History.php?page=1&breed=CU0&start=1999-01-01&end=2017-06-15&jys=shfe&pz=CU&hy=CU0&type=inner&name=%A1%E4%A8%AE%26%23182%3B11109' 55 | urls = [] 56 | 57 | for i in range(1,77): 58 | urls.append('http://vip.stock.finance.sina.com.cn/q/view/vFutures_History.php?page='+str(i)+'&breed=CU0&start=1999-01-01&end=2017-06-15&jys=shfe&pz=CU&hy=CU0&type=inner&name=%A1%E4%A8%AE%26%23182%3B11109') 59 | 60 | 61 | for url in urls: 62 | data = get_one_data(url) 63 | W2File(data) -------------------------------------------------------------------------------- /Google-Image/spider.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Google Image Spider 3 | 4 | ''' 5 | 6 | import requests 7 | from bs4 import BeautifulSoup 8 | 9 | 10 | SEARCHRUL = 'https://www.google.com/search?&safe=off&q={}&tbm=isch&tbs=itp:photo,isz:l' 11 | 12 | 13 | def get_html_text(url): 14 | '''获取网页的原始text''' 15 | headers = {} 16 | headers['User-Agent'] = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17" 17 | try: 18 | r = requests.get(url, timeout=9, headers=headers) 19 | r.raise_for_status 20 | r.encoding = r.apparent_encoding 21 | return r.text 22 | except: 23 | return 'error' 24 | 25 | 26 | def parse_img_url(q, nums): 27 | ''' 28 | 解析返回搜索图片的原始链接 29 | q : 搜索关键词 30 | nums: 返回的结果数量 最大值20 31 | ''' 32 | links = [] 33 | # 防止越界 34 | if nums > 20 or nums > 0: 35 | num = 20 36 | 37 | url = SEARCHRUL.format(q) 38 | print(url) 39 | html = get_html_text(url) 40 | if html != 'error': 41 | soup = BeautifulSoup(html, 'lxml') 42 | content = soup.find_all('div', class_='rg_meta', limit=nums) 43 | for link in content: 44 | rec = eval(link.text) 45 | links.append(rec['ou']) 46 | return links 47 | else: 48 | return 'error' 49 | 50 | 51 | res = parse_img_url('test', 15) 52 | 53 | for url in res: 54 | print(url) 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-crawler 2 | 3 | > 由于代码是比较早之前写的,抓取的网站目录结构可能有所变动 4 | > 所以部分代码可能不能使用了,欢迎正在学习爬虫的大家给这个项目**提PR** 5 | > 让更多的代码能跑起来~ 6 | 7 | 从零开始系统化的学习写Python爬虫。 8 | 主要是记录一下自己写Python爬虫的经过与心得。 9 | 同时也是为了分享一下如何能更高效率的学习写爬虫。 10 | IDE:Vscode Python版本: 3.6 11 | 12 | * 知乎专栏:https://zhuanlan.zhihu.com/Ehco-python 13 | 14 | 详细学习路径: 15 | ### 一:Beautiful Soup 爬虫 16 | 17 | * requests库的安装与使用 https://zhuanlan.zhihu.com/p/26681429 18 | * 安装beautiful soup 爬虫环境 https://zhuanlan.zhihu.com/p/26683864 19 | * beautiful soup 的解析器 https://zhuanlan.zhihu.com/p/26691931 20 | * re库 正则表达式的使用 https://zhuanlan.zhihu.com/p/26701898 21 | * bs4 爬虫实践: 获取百度贴吧的内容 https://zhuanlan.zhihu.com/p/26722495 22 | * bs4 爬虫实践: 获取双色球中奖信息 https://zhuanlan.zhihu.com/p/26747717 23 | * bs4 爬虫实践: 排行榜小说批量下载 https://zhuanlan.zhihu.com/p/26756909 24 | * bs4 爬虫实践: 获取电影信息 https://zhuanlan.zhihu.com/p/26786056 25 | * bs4 爬虫实践: 悦音台mv排行榜与反爬虫技术 https://zhuanlan.zhihu.com/p/26809626 26 | ------ 27 | ### 二: Scrapy 爬虫框架 28 | 29 | * Scrapy 爬虫框架的安装与基本介绍 https://zhuanlan.zhihu.com/p/26832971 30 | * Scrapy 选择器和基本使用 https://zhuanlan.zhihu.com/p/26854842 31 | * Scrapy 爬虫实践:天气预报&数据存储 https://zhuanlan.zhihu.com/p/26885412 32 | * Scrapy 爬虫实践:代理的爬取和验证 https://zhuanlan.zhihu.com/p/26939527 33 | * Scrapy 爬虫实践:糗事百科&爬虫攻防 https://zhuanlan.zhihu.com/p/26980300 34 | * Scrapy 爬虫实践:重构排行榜小说爬虫&Mysql数据库 https://zhuanlan.zhihu.com/p/27027200 35 | ------ 36 | ### 三: 浏览器模拟爬虫 37 | 38 | * Selenium模拟浏览器 https://zhuanlan.zhihu.com/p/27115580 39 | * 爬虫实践:获取快代理 https://zhuanlan.zhihu.com/p/27150025 40 | * 爬虫实践:漫画批量下载 https://zhuanlan.zhihu.com/p/27155429 41 | 42 | ### 四: 练手项目 43 | 44 | * 爬虫实践:螺纹钢数据&Cookies https://zhuanlan.zhihu.com/p/27232687 45 | * 爬虫实践:登录正方教务系统 https://zhuanlan.zhihu.com/p/27256315 46 | * 爬虫应用: requests+django实现微信公众号后台 https://zhuanlan.zhihu.com/p/27625233 47 | * 爬虫应用: 12306火车票信息查询 https://zhuanlan.zhihu.com/p/27969976 48 | * 爬虫应用: 利用斗鱼Api抓取弹幕 https://zhuanlan.zhihu.com/p/28164017 49 | * 爬虫应用: 获取支付宝账单信息 https://zhuanlan.zhihu.com/p/28537306 50 | * 爬虫应用:IT之家热门段子(评论)爬取 https://zhuanlan.zhihu.com/p/28806210 51 | * 爬虫应用:一号店 商品信息查询程序 https://zhuanlan.zhihu.com/p/28982497 52 | * 爬虫应用:搜狗输入法词库抓取 https://zhuanlan.zhihu.com/p/31186373 53 | * 爬虫应用:复古网盘游戏抓取 https://zhuanlan.zhihu.com/p/32420131 54 | * 爬虫应用:自动填写问卷星 https://zhuanlan.zhihu.com/p/36224375 55 | * 爬虫应用:腾讯漫画下载~ https://zhuanlan.zhihu.com/p/39578774 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Scrapy 爬虫框架/001.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 简单介绍scrapycXPATH选择器的使用 3 | ''' 4 | from scrapy.selector import Selector 5 | 6 | xml = ''' 7 | 8 | 9 |