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
| #include <stdio.h> | |
| #include <iostream> | |
| #include <opencv2/opencv.hpp> | |
| #include <opencv2/highgui/highgui.hpp> | |
| using namespace cv; | |
| using namespace std; | |
| /** @function main */ | |
| Mat equalizeIntensity(const Mat& inputImage) |
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
| #include <iostream> | |
| #include <opencv2/opencv.hpp> | |
| #include <opencv2/highgui/highgui.hpp> | |
| using namespace cv; | |
| int convertToWebSafe(int color) { | |
| //0 51 102 153 204 255 | |
| // 25 76 127 178 229 | |
| if (color >= 229) | |
| return 255; |
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
| def fetchM01(targetUrl, startPage=1, host ='https://www.mobile01.com'): | |
| global FETCH_COUNTER #int | |
| global ARTICLE_INFOS #array | |
| soup=getBsObj(targetUrl+'&p='+str(startPage)) | |
| if(soup == 1): | |
| sys.exit(1) | |
| if(soup): | |
| mainContent = soup.select_one('#maincontent') | |
| mainContent = mainContent.select_one('.tablelist.forumlist') | |
| mainContent = mainContent.tbody |
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
| def getBsObj(url): | |
| try: | |
| html=urlopen(url) | |
| except: | |
| print('open url fail') | |
| return 1 | |
| try: | |
| bsObj=BeautifulSoup(html.read(),'html.parser') | |
| except: |
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
| from bs4 import BeautifulSoup | |
| from urllib.request import urlopen | |
| import json | |
| import sys | |
| import re | |
| import io | |
| import time | |
| #def | |
| ARTICLE_NUM = int(input('How many article do you want?(Default:35) ') or 35 ) |
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
| def fetchM01Article(targetUrl,atPage=1,building = {}, datas=[]): | |
| def totalPageFilter(text): | |
| text = text.replace(" ", "") | |
| text = text.replace("\n", "") | |
| text = text[-(int(len(text)/2)+1):] | |
| rule = re.compile(r"[^0-9]") | |
| text = rule.sub('',text) | |
| if(text == ''): | |
| text = 0 | |
| return int(text) |
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
| [ | |
| { | |
| "Topic": "【心得】iPhone XR 開箱,拍照、螢幕效果比一比!", | |
| "Popularity": 31856, | |
| "ReplyCount": 27, | |
| "Datas": [ | |
| { | |
| "At": 0, | |
| "Poster": "科技狗", | |
| "Date": "2019-01-02 12:15", |
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
| from bs4 import BeautifulSoup | |
| from urllib.request import urlopen | |
| #func | |
| def getBsObj(url): | |
| try: | |
| html=urlopen(url) | |
| except: | |
| print('open url fail') | |
| return 1 |
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
| import socket #引入lib | |
| def print_machine_info(): #自訂副程式 | |
| host_name = socket.gethostname() | |
| ip_address = socket.gethostbyname(host_name) | |
| print("Host name: %s" %host_name) | |
| print("IP address: %s" %ip_address) | |
| if __name__ == '__main__': #main函式 | |
| print_machine_info() |
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
| import socket | |
| def get_remote_machine_info(): | |
| remote_host = 'www.python.org' #目標host | |
| try: #使用try except做例外處理 | |
| print ("IP address of %s: %s" %(remote_host, socket.gethostbyname(remote_host))) #印出結果 | |
| except socket.error as err_msg: #如果發生錯誤 | |
| print ("%s: %s" %(remote_host, err_msg)) #印出錯誤訊息 | |
| if __name__ == '__main__': |