Convert Figma logo to code with AI

Jack-Cherish logopython-spider

:rainbow:Python3网络爬虫实战:淘宝、京东、网易云、B站、12306、抖音、笔趣阁、漫画小说下载、音乐电影下载等

18,644
5,992
18,644
21

Top Related Projects

爬虫集合

一些非常有趣的python爬虫例子,对新手比较友好,主要爬取淘宝、天猫、微信、微信读书、豆瓣、QQ等网站。(Some interesting examples of python crawlers that are friendly to beginners. )

Python ProxyPool for web spider

😮python模拟登陆一些大型网站,还有一些简单的爬虫,希望对你们有所帮助❤️,如果喜欢记得给个star哦🌟

1,836

简单易用的Python爬虫框架,QQ交流群:597510560

16,692

A Powerful Spider(Web Crawler) System in Python.

Quick Overview

Jack-Cherish/python-spider is a comprehensive collection of Python web scraping projects and tutorials. It covers various scraping techniques for different websites and platforms, including social media, e-commerce, and entertainment sites. The repository serves as both a learning resource and a practical toolkit for developers interested in web scraping with Python.

Pros

  • Diverse range of scraping projects covering popular websites and platforms
  • Detailed explanations and comments in the code for educational purposes
  • Regular updates and maintenance by the author
  • Includes both basic and advanced scraping techniques

Cons

  • Some projects may become outdated as websites change their structure
  • Limited documentation in English (primarily in Chinese)
  • May require additional setup for certain dependencies or libraries
  • Some examples might not follow best practices for large-scale or production use

Code Examples

  1. Basic web scraping using requests and BeautifulSoup:
import requests
from bs4 import BeautifulSoup

url = 'https://example.com'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
title = soup.find('h1').text
print(f"Page title: {title}")
  1. Scraping with Selenium for dynamic content:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get('https://example.com')
element = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.ID, "dynamic-content"))
)
print(element.text)
driver.quit()
  1. Asynchronous scraping using aiohttp:
import aiohttp
import asyncio

async def fetch(session, url):
    async with session.get(url) as response:
        return await response.text()

async def main():
    urls = ['https://example1.com', 'https://example2.com', 'https://example3.com']
    async with aiohttp.ClientSession() as session:
        tasks = [fetch(session, url) for url in urls]
        responses = await asyncio.gather(*tasks)
        for response in responses:
            print(len(response))

asyncio.run(main())

Getting Started

To get started with the Jack-Cherish/python-spider projects:

  1. Clone the repository:

    git clone https://github.com/Jack-Cherish/python-spider.git
    
  2. Install required dependencies:

    cd python-spider
    pip install -r requirements.txt
    
  3. Choose a project from the repository and navigate to its directory.

  4. Run the Python script:

    python script_name.py
    

Note: Some projects may require additional setup or configuration. Refer to the individual project's README or comments for specific instructions.

Competitor Comparisons

爬虫集合

Pros of awesome-spider

  • Comprehensive collection of spider resources and projects
  • Well-organized with categories for different types of spiders
  • Includes a wide range of languages and frameworks

Cons of awesome-spider

  • Lacks detailed explanations or tutorials for each project
  • May not be as beginner-friendly as python-spider
  • Some listed projects might be outdated or no longer maintained

Code Comparison

python-spider example:

import requests
from bs4 import BeautifulSoup

url = 'https://example.com'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

awesome-spider doesn't provide direct code examples, as it's a curated list of resources. However, it links to various projects with their own implementations.

Summary

python-spider is more focused on providing practical Python-based web scraping examples and tutorials, making it ideal for beginners and those specifically interested in Python. awesome-spider, on the other hand, offers a broader overview of web scraping resources across multiple languages and frameworks, making it valuable for developers seeking diverse approaches to web scraping.

一些非常有趣的python爬虫例子,对新手比较友好,主要爬取淘宝、天猫、微信、微信读书、豆瓣、QQ等网站。(Some interesting examples of python crawlers that are friendly to beginners. )

Pros of examples-of-web-crawlers

  • More diverse examples covering various platforms (WeChat, Bilibili, Douban, etc.)
  • Includes practical applications like sending emails and generating word clouds
  • Better documentation with detailed explanations for each crawler

Cons of examples-of-web-crawlers

  • Less frequently updated compared to python-spider
  • Fewer stars and forks, indicating potentially less community engagement
  • Some examples may be outdated due to changes in target websites

Code Comparison

examples-of-web-crawlers (WeChat friends analysis):

itchat.auto_login(hotReload=True)
friends = itchat.get_friends(update=True)[0:]
male = female = other = 0
for i in friends[1:]:
    sex = i["Sex"]
    if sex == 1:
        male += 1
    elif sex == 2:
        female += 1
    else:
        other += 1

python-spider (Bilibili video downloader):

def download(self, url, name):
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36'}
    r = requests.get(url=url, headers=headers, stream=True)
    with open(name, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024):
            if chunk:
                f.write(chunk)

Both repositories offer valuable resources for learning web scraping in Python, with examples-of-web-crawlers providing a wider range of practical applications and python-spider offering more frequent updates and a larger community.

Python ProxyPool for web spider

Pros of proxy_pool

  • Focuses specifically on proxy management, providing a robust solution for maintaining and utilizing proxy pools
  • Offers a RESTful API for easy integration with other projects
  • Includes automatic proxy validation and scoring system

Cons of proxy_pool

  • More limited in scope compared to python-spider's diverse collection of web scraping examples
  • May require additional setup and maintenance for the proxy pool infrastructure
  • Less suitable for beginners looking for general web scraping tutorials

Code Comparison

proxy_pool example (proxy retrieval):

import requests

def get_proxy():
    return requests.get("http://127.0.0.1:5010/get/").json()

proxy = get_proxy().get("proxy")

python-spider example (basic web scraping):

import requests
from bs4 import BeautifulSoup

url = "https://example.com"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

proxy_pool is specialized for proxy management, while python-spider provides a broader range of web scraping examples and techniques. The choice between them depends on the specific needs of your project, with proxy_pool being more suitable for projects requiring extensive proxy usage and python-spider offering a wider variety of web scraping tutorials and examples.

😮python模拟登陆一些大型网站,还有一些简单的爬虫,希望对你们有所帮助❤️,如果喜欢记得给个star哦🌟

Pros of awesome-python-login-model

  • Focuses specifically on login models, providing a more specialized resource
  • Includes a wider variety of login examples for different websites and platforms
  • Offers more detailed explanations and comments in the code samples

Cons of awesome-python-login-model

  • Less comprehensive in terms of overall web scraping techniques
  • Fewer examples of data extraction and processing after login
  • May not be as frequently updated as python-spider

Code Comparison

python-spider:

def get_page(url):
    response = requests.get(url, headers=headers)
    return response.text

def parse_page(html):
    soup = BeautifulSoup(html, 'html.parser')
    # Extract data from soup

awesome-python-login-model:

def login(username, password):
    session = requests.Session()
    login_data = {'username': username, 'password': password}
    response = session.post(login_url, data=login_data, headers=headers)
    return session if response.status_code == 200 else None

def get_protected_content(session, url):
    response = session.get(url)
    # Process protected content

The code comparison shows that python-spider focuses more on general web scraping techniques, while awesome-python-login-model emphasizes the login process and accessing protected content.

1,836

简单易用的Python爬虫框架,QQ交流群:597510560

Pros of PSpider

  • More comprehensive and structured framework for building scalable spiders
  • Better documentation and code organization
  • Includes built-in support for distributed crawling

Cons of PSpider

  • Steeper learning curve due to its more complex architecture
  • Less frequently updated compared to python-spider
  • Fewer example scripts for specific use cases

Code Comparison

PSpider example:

from pspider import spider, parser

@spider.route()
def start_page(spider):
    yield "http://example.com"

@parser.route()
def parse_page(parser):
    title = parser.css("h1::text").extract_first()
    yield {"title": title}

python-spider example:

import requests
from bs4 import BeautifulSoup

url = "http://example.com"
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
title = soup.find("h1").text
print({"title": title})

PSpider offers a more structured approach with decorators and built-in parsing methods, while python-spider provides simpler, more straightforward scripts using popular libraries like requests and BeautifulSoup.

16,692

A Powerful Spider(Web Crawler) System in Python.

Pros of pyspider

  • More comprehensive framework with a web-based UI for managing crawlers
  • Built-in support for distributed crawling and task queue management
  • Extensive documentation and active community support

Cons of pyspider

  • Steeper learning curve due to its more complex architecture
  • May be overkill for simple scraping tasks
  • Less frequently updated compared to python-spider

Code Comparison

pyspider:

from pyspider.libs.base_handler import *

class Handler(BaseHandler):
    @every(minutes=24 * 60)
    def on_start(self):
        self.crawl('http://example.com/', callback=self.index_page)

    @config(age=10 * 24 * 60 * 60)
    def index_page(self, response):
        for each in response.doc('a[href^="http"]').items():
            self.crawl(each.attr.href, callback=self.detail_page)

python-spider:

import requests
from bs4 import BeautifulSoup

def crawl(url):
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    links = soup.find_all('a', href=True)
    for link in links:
        print(link['href'])

The pyspider example showcases its framework-based approach with decorators and callbacks, while python-spider demonstrates a simpler, script-based method using popular libraries like requests and BeautifulSoup.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

注:2020年最新连载教程请移步:Python Spider 2020

免责声明:

大家请以学习为目的使用本仓库,爬虫违法违规的案件:https://github.com/HiddenStrawberry/Crawler_Illegal_Cases_In_China

本仓库的所有内容仅供学习和参考之用,禁止用于商业用途。任何人或组织不得将本仓库的内容用于非法用途或侵犯他人合法权益。本仓库所涉及的爬虫技术仅用于学习和研究,不得用于对其他平台进行大规模爬虫或其他非法行为。对于因使用本仓库内容而引起的任何法律责任,本仓库不承担任何责任。使用本仓库的内容即表示您同意本免责声明的所有条款和条件。

Python Spider

原创文章每周最少两篇,后续最新文章会在【公众号】首发,视频【B站】首发,大家可以加我【微信】进交流群,技术交流或提意见都可以,欢迎Star!

微信群 公众号 B站 知乎 CSDN 头条 掘金

声明

  • 代码、教程仅限于学习交流,请勿用于任何商业用途!

目录

爬虫小工具

  • downloader.py:文件下载小助手

    一个可以用于下载图片、视频、文件的小工具,有下载进度显示功能。稍加修改即可添加到自己的爬虫中。

    动态示意图:

    image

爬虫实战

  • biqukan.py:《笔趣看》盗版小说网站,爬取小说工具

    第三方依赖库安装:

     pip3 install beautifulsoup4
    

    使用方法:

     python biqukan.py
    
  • baiduwenku.py: 百度文库word文章爬取

    原理说明:http://blog.csdn.net/c406495762/article/details/72331737

    代码不完善,没有进行打包,不具通用性,纯属娱乐。

  • shuaia.py: 爬取《帅啊》网,帅哥图片

    《帅啊》网URL:http://www.shuaia.net/index.html

    原理说明:http://blog.csdn.net/c406495762/article/details/72597755

    第三方依赖库安装:

     pip3 install requests beautifulsoup4
     
    
  • daili.py: 构建代理IPæ± 

    原理说明:http://blog.csdn.net/c406495762/article/details/72793480

  • carton: 使用Scrapy爬取《火影忍者》漫画

    代码可以爬取整个《火影忍者》漫画所有章节的内容,保存到本地。更改地址,可以爬取其他漫画。保存地址可以在settings.py中修改。

    动漫网站:http://comic.kukudm.com/

    原理说明:http://blog.csdn.net/c406495762/article/details/72858983

  • hero.py: 《王者荣耀》推荐出装查询小助手

    网页爬取已经会了,想过爬取手机APP里的内容吗?

    原理说明:http://blog.csdn.net/c406495762/article/details/76850843

  • financical.py: 财务报表下载小助手

    爬取的数据存入数据库会吗?《跟股神巴菲特学习炒股之财务报表入库(MySQL)》也许能给你一些思路。

    原理说明:http://blog.csdn.net/c406495762/article/details/77801899

    动态示意图:

    image

  • one_hour_spider:一小时入门Python3网络爬虫。

    原理说明:

    本次实战内容有:

    • 网络小说下载(静态网站)-biqukan
    • 优美壁纸下载(动态网站)-unsplash
    • 视频下载
  • douyin.py:抖音App视频下载

    抖音App的视频下载,就是普通的App爬取。

    原理说明:

  • douyin_pro:抖音App视频下载(升级版)

    抖音App的视频下载,添加视频解析网站,支持无水印视频下载,使用第三方平台解析。

    原理说明:

  • douyin:抖音App视频下载(升级版2)

    抖音App的视频下载,添加视频解析网站,支持无水印视频下载,通过url解析,无需第三方平台。

    原理说明:

    动态示意图:

    image

  • geetest.py:GEETEST验证码识别

    原理说明:

    无

  • 12306.py:用Python抢火车票简单代码

    可以自己慢慢丰富,蛮简单,有爬虫基础很好操作,没有原理说明。

  • baiwan:百万英雄辅助答题

    效果图:

    image

    原理说明:

    功能介绍:

    服务器端,使用Python(baiwan.py)通过抓包获得的接口获取答题数据,解析之后通过百度知道搜索接口匹配答案,将最终匹配的结果写入文件(file.txt)。

    手机抓包不会的朋友,可以看下我的早期手机APP抓包教程。

    Node.js(app.js)每隔1s读取一次file.txt文件,并将读取结果通过socket.io推送给客户端(index.html)。

    亲测答题延时在3s左右。

    声明:没做过后端和前端,花了一天时间,现学现卖弄好的,javascript也是现看现用,百度的程序,调试调试而已。可能有很多用法比较low的地方,用法不对,请勿见怪,有大牛感兴趣,可以自行完善。

  • Netease:根据歌单下载网易云音乐

    效果图:

    image

    原理说明:

    暂无

    功能介绍:

    根据music_list.txt文件里的歌单的信息下载网易云音乐,将自己喜欢的音乐进行批量下载。

  • bilibili:B站视频和弹幕批量下载

    原理说明:

    暂无

    使用说明:

     python bilibili.py -d 猫 -k 猫 -p 10
    
     三个参数:
     -d	保存视频的文件夹名
     -k	B站搜索的关键字
     -p	下载搜索结果前多少页
    
  • jingdong:京东商品晒单图下载

    效果图:

    image

    原理说明:

    暂无

    使用说明:

     python jd.py -k 芒果
    
      三个参数:
     -d	保存图片的路径,默认为fd.py文件所在文件夹
     -k	搜索关键词
     -n  	下载商品的晒单图个数,即n个商店的晒单图
    
  • zhengfang_system_spider:对正方教务管理系统个人课表,个人学生成绩,绩点等简单爬取

    效果图:

    image

    原理说明:

    暂无

    使用说明:

     cd zhengfang_system_spider
     pip install -r requirements.txt
     python spider.py
    

其它

  • 欢迎 Pull requests,感谢贡献。

更多精彩,敬请期待!

wechat