Git Product home page Git Product logo

vnnews_crawler's Introduction

VnNews crawler

This is a Python script for crawling articles from the VnExpress news website and saving them to CSV files. You can specify the category of articles and the number of pages to crawl using command-line arguments.

Installation

Clone this repository to your local machine:

git clone https://github.com/linhthi/vnnews_crawler.git

Install the required dependencies by running the following command in the terminal:

pip install -r requirements.txt

Usage

You can run the script using the following command in the terminal:

python vnexpress.py -c <category> -p <pages> -o <output_folder>

Replace category with the category of articles you want to crawl (e.g. giao-duc, khoa-hoc, the-thao, kinh-doanh, suc-khoe, the-gioi, giai-tri, du-lich, so-hoa, thoi-su, phap-luat, or all for all categories), and page with the number of pages you want to crawl (default is 1).

For example, to crawl all articles from the giao-duc category on the first 2 pages, run the following command:

python vnexpress.py -c giao-duc -p 2 -o data_vnexpress

The script will create a directory named dataset_vnexpress in the current directory and save the crawled articles to CSV files inside this directory, with each file named category_pageX.csv, where category is the name of the category and X is the page number.

Output format

The CSV files contain the following fields for each article:

  • id: the unique ID of the article
  • title: the title of the article
  • url: url of the article
  • author: the author of the article
  • updatetime: the date and time when the article was last updated
  • wordcount: the word count of the article
  • publication: the name of the publication that the article belongs to
  • tags: the tags associated with the article
  • content: the content of the article

License

This script is released under the MIT License.

vnnews_crawler's People

Contributors

giangbang avatar linhthi avatar

Watchers

 avatar

Forkers

giangbang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.