Git Product home page Git Product logo

google-scholar-crawler's Introduction

google-scholar-crawler

這是我練習寫的一個爬取Google Scholar Search Page的網路爬蟲程式

1. 將Google Search Page上,Paper的標題,年份和網址['title', 'year', 'url'],以CSV檔案格式記錄下來

2. 將Google Search Page上,含有Tag (如[PDF], [HTML])的連結,以PDF檔案格式下載下來

Getting Started

本程式適用於mac,以Python 2.7.10執行,使用函式庫requests, BeautifulSoup, pdfkit,建議皆以pip安裝

安裝pdfkit前,需要下載wkhtmltopdf

在Terminal下載程式碼

$ git clone https://github.com/linhung0319/google-scholar-crawler.git

How to Use

輸入你想找的關鍵字,到達Search Page的第一頁,並複製此頁的網址

2. 進入google_crawler.py

將複製的網址放入start_url, start_url = '網址'

3. p_key放入想找的關鍵字,n_key放入不想找的關鍵字

在Search Page中,每一格的標題和內容,若含有p_key中的字,則Crawler會傾向於抓取此篇Paper

在Search Page中,每一格的標題和內容,若含有n_key中的字,則Crawler會傾向於忽略此篇Paper

在上圖中,因為我想找跟聲音相關,不想找跟光學相關的Paper,所以p_key中放入跟聲音相關的字,n_key中放入跟光學相關的字

4. 設定 page = 數字 ,可以設定要抓取幾頁的Google Search Page

設定太多頁會誘發Google的robot check

5. 開始執行程式

在Terminal中執行 google_crawler.py

$ python google_crawler.py

會將抓取的資料 ('title', 'year', 'url',...) ,存在result.pickle中

然後,在Terminal中執行 csvNdownload.py

$ python csvNdownload.py

將資料轉為CSV檔,存入CSV資料夾

下載具有Tag (PDF, HTML)的連結轉為PDF檔,分別存入PDF,HTML資料夾

Google Robot Check

Google Search Page 會進行反爬蟲偵測,如果下載或是觀看網頁的手速太快,他會懷疑你是機器人,並且禁止掉你的IP位址

目前想到的最簡單的方法,是使用VPN,當被認為是機器人,就使用VPN馬上改變自己的IP位址

現在網路上有許多的免費VPN可以下載

若在跑Crawler的時候出現訊息

__findPages - Can not find the pages link in the start URL!!
__findPages - 1.Google robot check might ban you from crawling!!
__findPages - 2.You might not crawl the page of google scholar

解決方式為使用VPN,轉換IP

google-scholar-crawler's People

Contributors

linhung0319 avatar

Watchers

James Cloos avatar Zhao Yang avatar

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.