如何第一次爬蟲就上手python

Outsider987
Feb 20, 2021

--

爬蟲是甚麼,爬蟲可以吃嗎?

爬蟲核心就是”把別人的資料庫都變成我的資料庫

但是請注意,請當個有品的爬蟲,因為爬蟲會發出request對網站進行訪問,如果過量會讓網站掛掉的,網站擁有者也會查出爬蟲的IP並且進行封鎖(雖然有其他方法(`Д´)~~~~~~)

在這邊我先列出幾項讓大家遵守(記得給我大聲在心裡默念):

  • 只抓取你需要的資料,不要全部拿走
  • 記得好好利用sleep function(你不知道sleep?? 之後會在後面的文章再給大家講解)

在於資料庫會有一個max_connections_per_hour 的限制,假如網站的流量限制太低,你可能爬到一半網站就掛了,所以請不要讓網站給掛了,你爬不到資料,對方的作者也無法提供網站的內容給大家

在了解爬蟲之前你必須先知道html、CSS、跟基本的python 語法,這樣才能將爬蟲運用的自如,這邊我先把基本環境列在下面,下一篇文章我再來講解一下基本的html知識

  • python :3.6 (點我去官網下載)
  • Scrapy pip install scrapy
  • BeautifulSoup pip install beautifulsoup
  • urllib3 pip install urllib3

上面的指令請你打開終端機,並且把它們確實安裝

說了這麼多,第一篇文章你做了甚麼?

你良心不會痛嗎
你良心不會痛嗎
你真的忍心嗎

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Outsider987
Outsider987

Written by Outsider987

Hi, this is Victor In my college I was majors medical chemistry ,but I found the programing is interesting stuff I never met ,so I start to learning computer s

No responses yet

Write a response