-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
488 additions
and
124 deletions.
There are no files selected for viewing
File renamed without changes.
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.keys import Keys | ||
import time | ||
from selenium.webdriver.common.by import By | ||
|
||
# Open the 2048 game website using Selenium | ||
driver = webdriver.Chrome() | ||
driver.get("https://play2048.co/") | ||
time.sleep(3) | ||
while True: | ||
driver.find_element(By.TAG_NAME, 'body').send_keys(Keys.ARROW_UP) | ||
time.sleep(0.1) | ||
driver.find_element(By.TAG_NAME, 'body').send_keys(Keys.ARROW_RIGHT) | ||
time.sleep(0.1) | ||
driver.find_element(By.TAG_NAME, 'body').send_keys(Keys.ARROW_DOWN) | ||
time.sleep(0.1) | ||
driver.find_element(By.TAG_NAME, 'body').send_keys(Keys.ARROW_LEFT) | ||
time.sleep(0.1) | ||
|
Binary file not shown.
Binary file not shown.
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
from selenium import webdriver | ||
import urllib.request | ||
import time | ||
from selenium.webdriver.common.by import By | ||
import requests | ||
|
||
driver = webdriver.Chrome() | ||
driver.get("https://twitter.com/cat_auras") | ||
time.sleep(5) | ||
images = driver.find_elements(By.TAG_NAME, 'img') | ||
for i, image in enumerate(images): | ||
print("正在下載第" + str(i) + "張圖片") | ||
src = image.get_attribute('src') | ||
response = requests.get(src, stream=True) | ||
if response.status_code == 200: | ||
with open(f'image{i}.png', 'wb') as out_file: | ||
out_file.write(response.content) |
Binary file not shown.
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from selenium import webdriver | ||
import urllib.request | ||
import time | ||
from selenium.webdriver.common.by import By | ||
import requests | ||
from selenium.webdriver.common.keys import Keys | ||
from selenium.webdriver.common.action_chains import ActionChains | ||
|
||
driver = webdriver.Chrome() | ||
|
||
driver.get("https://twitter.com/cat_auras") | ||
|
||
time.sleep(3) | ||
|
||
for i in range(3): | ||
actions = ActionChains(driver) | ||
actions.send_keys(Keys.PAGE_DOWN).perform() | ||
time.sleep(1) | ||
|
||
time.sleep(3) | ||
|
||
images = driver.find_elements(By.TAG_NAME, 'img') | ||
for i, image in enumerate(images): | ||
print("正在下載第" + str(i) + "張圖片") | ||
src = image.get_attribute('src') | ||
response = requests.get(src, stream=True) | ||
if response.status_code == 200: | ||
with open(f'image{i}.png', 'wb') as out_file: | ||
out_file.write(response.content) |
Large diffs are not rendered by default.
Oops, something went wrong.
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