This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import win32com.client | |
from PIL import Image | |
ppt_path = input('請輸入PPT檔案絕對路徑:') | |
long_sign = input('是否產生長圖(Y/N):') | |
def ppt2jpg(): | |
output_path = ppt_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original from https://stackoverflow.com/a/5967539 | |
# 使用sort()方法時需要注意資料型態必須為list | |
import re | |
def atoi(text): | |
return int(text) if text.isdigit() else text | |
def natural_keys(text): | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install streamlink | |
# change to your favorite download folder | |
# cd path/To/Your/DownloadFolder | |
# type the following command in your CMD | |
# streamlink --hls-live-edge 99999 --hls-segment-threads 5 -o "video.mp4" https://www.youtube.com/watch?v=hHW1oY26kxQ best | |
# To escape the program, press CTRL+C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**1 - 爬蟲時若使用Chrome瀏覽器的XPath抓取套件,出現tbody要自行刪除** | |
**2 - Google試算表的ImportXML函數抓取資料** | |
=importxml(URL, XPath_query) | |
#URL為目標頁面 | |
#XPath_query為透過XPath套件抓取的路徑 | |
#以 &儲存格位置來代表數值變數,如&B1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 程式碼來自https://shareboxnow.com/python-google-drive-1/、https://shareboxnow.com/python-google-drive-2/,本人僅作紀錄使用 | |
# 我的Medium部落格介紹:https://medium.com/@yanweiliu/upload-your-file-to-google-drive-with-python-28f7e5a7ed8b | |
from __future__ import print_function | |
import os | |
import io | |
import time | |
from googleapiclient.discovery import build | |
from googleapiclient.http import MediaFileUpload, MediaIoBaseDownload | |
from httplib2 import Http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from pytrends.request import TrendReq | |
pytrend = TrendReq(hl='en-US', tz=360) | |
keywords = ['Python', 'R'] | |
pytrend.build_payload( | |
kw_list=keywords, | |
cat=0, | |
timeframe='today 3-m', | |
geo='TW', | |
gprop='') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dot_trick(username): | |
emails = list() | |
username_length = len(username) | |
combinations = pow(2, username_length - 1) | |
padding = "{0:0" + str(username_length - 1) + "b}" | |
for i in range(0, combinations): | |
bin = padding.format(i) | |
full_email = "" | |
for j in range(0, username_length - 1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
res = requests.get('https://ipinfo.io/') | |
data = res.json() | |
#print(data) | |
location = data['loc'].split(',') | |
city=data['city'] | |
country=data['country'] | |
lat=float(location[0]) | |
log=float(location[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assume that you have collected file links with web crawler or any other method. | |
# We will use requests, wget, concurrent.futures to download our file | |
import requests | |
import wget | |
import concurrent.futures | |
with open('download_link.txt','r') as f: | |
url_list = [str(line) for line in f.readlines()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python list usage | |
list1.append() # 加到最後面 | |
list1.insert(0,var) # 加到指定位置 | |
list1.extend(list2) # 將list2合併到list1 | |
list1.remove("C") # 移除list1中的"C" | |
list1.pop(0) # 刪除第0個項目 | |
list1.pop() # 刪除最後1個項目 | |
list1.clear() # 清空list1 | |
list1.count() # 計算有多少項目 |