Last active
May 3, 2022 06:31
-
-
Save wonsolution/f80a2e962b2947733aca6b78c145ff16 to your computer and use it in GitHub Desktop.
Create a Macro
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 intsall selenium | |
... | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import time | |
import pyautogui as ag | |
#window 창 열기 | |
driver = webdriver.Chrome('D:/temp/chromedriver.exe') | |
url='https://www.daangn.com/' | |
driver.get(url) | |
#검색하기 | |
search = '//input[@id="header-search-input"]' | |
search_win = driver.find_element_by_xpath(search) | |
search_win.send_keys('캠핑') | |
search_win.send_keys(Keys.ENTER) | |
print('search success') | |
while 1: | |
ag.click(1891,331) | |
time.sleep(1) | |
ag.hotkey('F5') | |
print('update_최신정보로 바꿈') | |
time.sleep(180) |
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 requests beautifulsoup4 lxml | |
... | |
import requests | |
from bs4 import BeautifulSoup | |
import time | |
keyword = '믹서기' | |
pre_price ="" | |
pre_ahref ="" | |
while 1 : | |
print ("Search ninjin !!!") | |
url = 'https://www.daangn.com/search/{}'.format(keyword) | |
r = requests.get(url) | |
bs = BeautifulSoup(r.content,'lxml') | |
divs = bs.select('div.articles-wrap') #select의 결과는 list이다. | |
# print(divs) | |
d = divs[0] | |
price = d.select('p.article-price')[0].text | |
alink = d.select('a.flea-market-article-link')[0] | |
ahref = "https://www.daangn.com/" + alink.get("href") | |
print(price) | |
print(ahref) | |
if pre_ahref == "": | |
print("skip send message first time") | |
elif pre_ahref == ahref: | |
print("skip send message same item") | |
else: | |
print("send message new item update!!!!") | |
print("send message new item update!!!!") | |
print("send message new item update!!!!") | |
pre_ahref = ahref | |
time.sleep(180) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment