12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- from seleniumwire import webdriver # Import from seleniumwire
- import time
- import requests
- import sys
- # Create a new instance of the Chrome driver
- headers = {
- "Authorization": "Bearer " + "Vt5YH5YvMwfz2m5KSpFMLLnJXoAM4uR7Ls5EQ68fw3l",
- "Content-Type": "application/x-www-form-urlencoded"
- }
- def send_msg(kw,original_url):
- params = {"message": "HHH破圖偵測: "+kw+" 頁面:"+original_url}
- r = requests.post("https://notify-api.line.me/api/notify",headers=headers, params=params)
- #original_url='https://hhh.com.tw/columns/detail/4300/'
- #original_url='https://www.hhh.com.tw/'
- original_url='https://m.hhh.com.tw/hhh-home-mb/index.html'
- if len(sys.argv)>=2:
- original_url=sys.argv[1]
- print(original_url)
- options = webdriver.ChromeOptions()
- options.add_argument('--headless')
- options.add_argument('--disable-gpu')
- options.add_argument('--incognito')
- options.add_argument('--no-sandbox')
- options.add_argument('--disable-dev-shm-usage')
- #driver = webdriver.Chrome(desired_capabilities=options.to_capabilities())
- driver = webdriver.Chrome(chrome_options=options)
- # Go to the Google home page
- #driver.get('https://hhh.com.tw/cases/detail/d/12428/')
- driver.get(original_url)
- time.sleep(15)
- # Access requests via the `requests` attribute
- for request in driver.requests:
- if request.response:
- if int(request.response.status_code)>=404:
- if 'jpg' in request.url or 'png' in request.url:
- send_msg(request.url,original_url)
- print(
- request.url,
- request.response.status_code,
- request.response.headers['Content-Type']
- )
- driver.quit()
- sys.exit()
- # else:
- # print(request.url)
|