This file contains hidden or 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
# Need to create a YZUActivity.txt | |
from selenium import webdriver | |
import time | |
import requests | |
from bs4 import BeautifulSoup | |
URL='https://portalx.yzu.edu.tw/PortalSocialVB/FMain/PageActivityAll.aspx' | |
#https://portalx.yzu.edu.tw/PortalSocialVB/FPage/PageActivityDetail.aspx?Menu=Act&ActID=XXXX | |
driver = webdriver.Chrome(r"C:\Software\chromedriver_win32\chromedriver.exe") # depend on your driver's location | |
driver.get(URL) |
This file contains hidden or 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
/* GIF : https://imgur.com/9ym87uj | |
* From Line 4~147 & Line 332~End are generated by shadowfox | |
* Line 150~331 are for auto-hiding sidebar, tabs, navigator bar, bookmark bar | |
*/ | |
:root { | |
--magenta-50: #ff1ad9; | |
--magenta-60: #ed00b5; | |
--magenta-70: #b5007f; | |
--magenta-80: #7d004f; | |
--magenta-90: #440027; |
This file contains hidden or 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
""" | |
scrape Yahoo Currency , output to Excel | |
請先新建一個Excel,命名為:Currency.xlsx | |
並增加22個sheets, 總共23個sheets , 名稱分別改為'美元', '澳幣', '加拿大幣', | |
'港幣', '英鎊', '瑞士法郎', '日圓', '歐元', '紐西蘭幣', '新加坡幣', | |
'南非幣', '瑞典克朗', '泰銖', '人民幣', '印度幣', '丹麥幣', '土耳其里拉', | |
'墨西哥披索', '越南幣', '菲律賓披索', '馬來西亞幣', '韓圜', '印尼盾' | |
40行請改成自己Excel的路徑 """ | |
import requests | |
from bs4 import BeautifulSoup |
This file contains hidden or 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
# 請先新建一個Excel,命名為:Temperature.xlsx, 並增加sheets以配合38行 並命名為 "桃園","內壢","中壢","高雄","台東" | |
# 36行請改成自己Excel的路徑 | |
import requests | |
import urllib.parse | |
import time | |
import openpyxl | |
import os | |
def weather_yahooAPI(Fcity,workbook): | |
res=requests.get("https://query.yahooapis.com/v1/public/yql?q=SELECT%20woeid%20FROM%20geo.places%20WHERE%20text%20IN(%22"+urllib.parse.quote(Fcity)+"%22)%20AND%20country%20%3D%20%22Taiwan%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys") | |
data=res.json() |
This file contains hidden or 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
# | |
# Scrape Yahoo Stock , output to Excel | |
# 請先新建一個Excel,命名為: stock_price_data.xlsx, 並增加一個sheet, 名稱改為TW2330,TW3711 | |
# 26行請改成自己Excel的路徑 | |
from bs4 import BeautifulSoup | |
import requests | |
import time | |
import os | |
import openpyxl |
This file contains hidden or 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
/* | |
Question: https://leetcode.com/problems/2-keys-keyboard/description/ | |
*/ | |
class Solution { | |
public: | |
int minSteps(int n) { | |
int n_temp = n; | |
if(n == 1 ) return 0; | |
int result = 0; | |
while(n%2 == 0) |
This file contains hidden or 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
class Solution { | |
public: | |
string reverseString(string s) { | |
string temp; for(string::reverse_iterator rit=s.rbegin();rit!=s.rend();rit++) temp.push_back(*rit); | |
return temp; | |
} | |
}; |
This file contains hidden or 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
class Solution { | |
public: | |
int integerBreak(int n) { | |
if(n == 2 || n == 3) return n-1; | |
if(n == 4) return 4; | |
int num = n/3; | |
int sum = 1; | |
if(n%3 == 1) sum = 4, --num; | |
else if(n%3 == 2) sum = 2; | |
while(num--) |
This file contains hidden or 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
class Solution | |
{ | |
public: | |
bool judgeCircle(string moves) | |
{ | |
int ud = 0 , lr = 0; | |
for(int i = 0; i < moves.length(); i++) | |
{ | |
switch(moves[i]) | |
{ |
This file contains hidden or 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
class Solution { | |
public: | |
int findPoisonedDuration(vector<int>& ts, int dur) { | |
unsigned int temp=0; | |
for(int i=0;i < (int)ts.size()-1 ; i++){ | |
if( (int)dur-ts[i+1]+ts[i] > 0) | |
temp+=(int)dur-ts[i+1]+ts[i]; | |
} | |
return (int)dur*ts.size()-temp; | |
} |