该选择哪个语言开发爬虫?
需要开发个采集腾讯、新浪微博的评论数据。
如果直接使用官方提供的API,会有很多数据获取不到。所以可能得自己写了。
我主要是想使用C++来开发的,其次才是PHP。在没办法的情况下,才会考虑使用python进行开发!
网上大概了解了下,很多采集程序都是使用python来开发的。因为python的网络库很多,很丰富,开发起来方便快捷。
PHP的也有个snoopy类库,C++的就不清楚了。
不知道,C++中有没有这方面的爬虫类库推荐呢?
回复内容:
需要开发个采集腾讯、新浪微博的评论数据。
如果直接使用官方提供的API,会有很多数据获取不到。所以可能得自己写了。
我主要是想使用C++来开发的,其次才是PHP。在没办法的情况下,才会考虑使用python进行开发!
网上大概了解了下,很多采集程序都是使用python来开发的。因为python的网络库很多,很丰富,开发起来方便快捷。
PHP的也有个snoopy类库,C++的就不清楚了。
不知道,C++中有没有这方面的爬虫类库推荐呢?
参考
C/C++ 网络爬虫
推荐Python。有requests等类库。
也有scrapy这样的框架。
python 唯一的好处就是 request 库真的很方便
我以前都是用 php 做爬虫的,现在都改用 python 了
其实用 JavaScript 也是很好的,node 或者 phantomJS
因为很多时候你不仅要把 HTML 爬下来,还要解析;而 python 的 DOM 库简直糟糕透顶;比如 BeautifulSoup,很多操作就非常不方便;相比之下,js 进行 DOM 操作就方便多了
弱弱的推荐一下 php 的 goutte
毫不犹豫golang
用python 没有原因
表示采用java,jsoup,http://www.husters.cn/ 抓爬的
- 有较好地html获取和解析支持。
- 有较好地并行控制。
- 方便处理异步任务。
- 容易开发DSL。(假如你需要用户自定义抓取路径的话。)
以前写过好几个版本的爬虫,供参考。http://niejason.sinaapp.com/?p=66
snoopy类库很久以前用过,不过感觉不是很好用。功能一般。
其实爬虫最网页请求那一块比较容易实现,也没有什么好说的。其实最主要是对请求回来的数据处理,分析。
所以我觉得用node.js会是很好的选择。
看看那位童鞋推荐下node.js有什么好的库。
node.js的jquery也不错。。。
建议用node, phamtomjs, node的jQuery, 还有jsdom, node下面很多解析html的包,非常方便
我觉得不是说选择哪个语言,主要是看开发者对哪个语言最熟悉。
如果是我的话,我会用 Node.js
Node.js 有一个 Cheerio 库,用来解析 HTML 效率十分不错。它的 API 风格是类似 jQuery 的。
啥都不说,肯定是python
需要开发个采集腾讯、新浪微博的评论数据。
目的明确了,解决的思路也不难。你的爬虫的主要功能就是
- 能向服务器进行通信,返回你需要页面的内容
- 解析页面源码,挖掘出你需要的信息
python是一个不错的推荐,解决两个问题都有完善的库。
比如urllib2解决http请求,lxml 解决页面源码的解析(解析成html树)。
关键步骤就是在解析后生成的html树中,找到所需信息,需要自己完成:
分析信息在html树中所在的位置,并告诉你的程序去对应位置(利用xpath来定位)抓信息
写过一个python抓取douban日志名称,URL,评论数,发布时间的爬虫。
能解决基本的挖掘需要后,再来考虑如何能更快及应对大型数据,目前了解的方法有iterparse方法,多线程等。
p.s
为什么是lxml?参考lxml performance
爬虫基本上就是网页抓去+内容分析了吧。
我也建议选择类库简单丰富的语言,比如Python和Ruby应该都不错。
Ruby可以选择的有Crul,mechanize,nokogiri,hpricot等。
php里有phpQuery,语法和jquery差不多,非常的好用!
Perl
竟然没人推荐..
golang 是个不错的选择
用python吧,你会发现有很多优点。。。
每个语言都可以,基本的爬虫只要涉及到一些HTTP请求和文档解析就能做出来。
Python有Scrapy等框架,上手比较快,可以研究一下。
爬虫无非就是获取网页内容,解析内容,正则出想要的数据,其实对于网页内容获取,任何语言都能获取,注意代理服务器防封IP,并行抓取等技术,个人感觉php 获取网页内容还是不错的,至于解析网页内容,基本上都是DOM的操作,那最佳选择还是nodejs,里边的cheerio很好的解决树形结构数据。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

CMS stands for Content Management System. It is a software application or platform that enables users to create, manage, and modify digital content without requiring advanced technical knowledge. CMS allows users to easily create and organize content
