Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
"""
Created on Tue May 12 02:46:22 2020
@author: Zino
"""
# 導入 模組(module)
import requests
# 把 到 ptt 八卦版 網址存到URL 變數中
# 導入 模組(module)
import requests
# 把 到 ptt 八卦版 網址存到URL 變數中
URL = "https://www.ptt.cc/bbs/Gossiping/index.html"
# 發送get 請求 到 ptt 八卦版
response = requests.get(URL)
# 印出回傳網頁程式碼
print(response.text)
@linzino7
linzino7 / covid_19.py
Created May 4, 2020 19:18
第一支網頁爬蟲:你也可以輕鬆爬取台灣第一位武漢肺炎確診資訊!(含影片與程式碼)
# -*- coding: utf-8 -*-
"""
Created on Mon May 4 01:59:51 2020
@author: Zino
dataset:https://data.gov.tw/dataset/120711
"""
# 導入模組(module)
import requests
# import requests 套件包
import requests
# GET請求抓資料
page = requests.get('https://www.google.com.tw/')
#印出網頁程式碼
print(page.text)
@linzino7
linzino7 / example.py
Last active April 28, 2020 19:05
阻擋新手學習[多頁網路爬蟲]的關鍵資料處理思維-累加 (內含影片)
# -*- coding: utf-8 -*-
import random, string
def get_one_pagedata(i):
'''
假設這個function爬取某一網頁資料。
先用亂數給予一個英文大小寫文字替代。
'''
content = random.choice(string.ascii_letters)
@linzino7
linzino7 / matplotlib_two_scales.py
Created January 15, 2019 09:13
X axis in matplotlib with different scales
# 將不同資料長度畫在不同的為度上
# ref https://matplotlib.org/examples/axes_grid/demo_parasite_axes2.html
import matplotlib.pyplot as plt
x_values1=[1,2,3,4,5]
y_values1=[1,2,2,4,1]
x_values2=[-1000,-800,-600,-400,-200,-100,0]
y_values2=[10,20,39,40,50,60,10]
Sales CompPrice Income Advertising Population Price ShelveLoc Age Education Urban US
1 9.5 138 73 11 276 120 Bad 42 17 Yes Yes
2 11.22 111 48 16 260 83 Good 65 10 Yes Yes
3 10.06 113 35 10 269 80 Medium 59 12 Yes Yes
4 7.4 117 100 4 466 97 Medium 55 14 Yes Yes
5 4.15 141 64 3 340 128 Bad 38 13 Yes No
class Command:
def redo(self, **kwargs):
abstract
def undo(self, **kwargs);
abstract
class UploadImgurCommand extend Command:
def redo(self, **kwargs):
image = kwargs['image'];
@linzino7
linzino7 / Python3decode.py
Created January 26, 2018 09:22
Python3 bytes.decode() 當遇到字串一樣時python 判別
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 19 17:34:34 2018
當遇到字串一樣時python 判別
@author: zino
"""
@linzino7
linzino7 / APS_TypeError_fix_by__cell__.py
Created December 27, 2017 05:59
Python APScheduler:TypeError: func must be a callable or a textual reference to one . Fix by __cell__.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 26 16:18:35 2017
@author: zino
"""
from datetime import datetime
import time