from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.set_window_size(1000,1000) #控制視窗大小
driver.get('https://comicbus.live/online/manga_9199.html?ch=8005')

阿亮 發表在 痞客邦 留言(0) 人氣()

import numpy as np
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt

阿亮 發表在 痞客邦 留言(0) 人氣()

pip install opencv--python

##可使用 confidence來解決圖像誤差

sure =pyautogui.locateOnScreen("back.png",confidence=0.95) 

while True:
            print("尋找背景")

阿亮 發表在 痞客邦 留言(0) 人氣()

import pyautogui
import time

time.sleep(2)
#點擊一次編輯器(在任意可填寫的空白處)

阿亮 發表在 痞客邦 留言(0) 人氣()

介面.png

import time
#系統準備時間
time.sleep(2)

阿亮 發表在 痞客邦 留言(0) 人氣()

import pyautogui

#屏幕大小
size=pyautogui.size()
print(size)

阿亮 發表在 痞客邦 留言(0) 人氣()

import requests
from bs4 import BeautifulSoup

res=requests.get('https://www.ptt.cc/bbs/joke/index.html')
soup=BeautifulSoup(res.text,'lxml')

阿亮 發表在 痞客邦 留言(0) 人氣()

requests.get之後 若遇到目前無法找到頁面

F12>Documents >Headers>Requests Headers送請求時的表投 >User-Agent #偽裝代理服務

import requests

head={'User-Agent' : 'xxxxxxx'}

res=requests.get(url,headers=head)

阿亮 發表在 痞客邦 留言(0) 人氣()

import requests

res=requests.get("url",verify=False) #遇到SSLError 可以用verify繞過憑證檢查

print(res.text)

from bs4 import BeautifulSoup

soup = BeautifulSoup(res.text, "lxml")  #也有html.parser

阿亮 發表在 痞客邦 留言(0) 人氣()

anaconda安裝用Selenium

主要是因為爬蟲沒辦法直接看到JS的渲染

from selenium import webdriver

driver = webdriver.PhantomJS(executable_path=r'C:\Users\USER\Desktop\phantomjs-2.1.1-windows\phantomjs-2.1.1-windows\bin\phantomjs.exe')  # PhantomJs
driver.get('http://pala.tw/js-example/')  # 輸入範例網址,交給瀏覽器 

阿亮 發表在 痞客邦 留言(0) 人氣()

-------------------------------------------------------------------------------------------------------------------顯示兩張圖figure
x=np.linspace(-1,1,50)座標-1到1間有五十個點
y1=2*x+1
y2=x**2
plt.figure()第一張圖

阿亮 發表在 痞客邦 留言(0) 人氣()

import matplotlib.pyplot as plt
data = pd.DataFrame(np.random.randn(1000, 5), 顯示五行數字columns是ABCDE 5個英文字就要數字5
index=np.arange(1000),
columns=list("ABCDE"))
data=data.cumsum()數據累加

阿亮 發表在 痞客邦 留言(0) 人氣()

1 2 3
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。