using Selenium RC in python, select_frame not grabbing frame - python
Trying to get the frame from the html source below using the following code:
idx = self.selenium.get_element_index("GEPNav")
idx = self.selenium.get_element_index("TOCFrames")
frame = self.selenium.select_frame("TOCFrames")
the 2 calls to get_element_index are for testing and they work, but the call to select_frame() returns None. Not sure why....
<html>
<head>
<TITLE>NYSE Arca Bylaws and Rules</TITLE>
<link rel="stylesheet" href="/PCX/styles/GEP.css">
<script language="javascript" src="misc.js"></script>
<META Http-Equiv="Cache-Control" Content="no-cache">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Expires" Content="0">
</head>
<script language="javascript" src="RenderTOC.js"></script>
<script language="javascript">
var IntervalID = 0;
IntervalID = window.setInterval('setTimer()', 2000);
</script>
<frameset rows="188, *" border="0" >
<frame src="/PCXTools/ExchangeNav.asp?SelectedNode=chp_1_1&manual=/PCX/pcxe/pcxe-rules/" name="GEPNav" id="GEPNav" scrolling="no" FRAMEBORDER="0" noresize marginwidth="0" marginheight="0">
<frame src="/PCXTools/PlatformTOCFrame.asp?SelectedNode=chp_1_1&manual=/PCX/pcxe/pcxe-rules/#chp_1_1" Name="TOCFrames" id="TOCFrames" scrolling="no" FRAMEBORDER="0" noresize marginwidth="0" marginheight="0">
</frameset>
<noframes>
To be viewed properly, this page requires frames.
</noframes>
Related
Authenticate against the API, include your API key in the 'Authorization' header, prefixed with 'Key ', in every request
As a seller on a marketplace, I would like to access and automate changes (in prices, quantity...etc) to my product offers against competitors on those offers through the marketplace's API("https://seller-api.takealot.com/api-docs/swagger.json") in python. How can I go about doing this? I am supposed to include my API key in an Authorization header to each request in order to be correctly authorised against the API. But I am stuck here, anyone to help please? I am very new to APIs. The documentation says: To authenticate against the API, include your API key in the 'Authorization' header, prefixed with 'Key ', in every request. Example: 'Authorization: Key yourapikey' Below is my code: import requests import secrets import csv url1 = 'https://seller.takealot.com/api/seller-api/offers' url2 = 'https://seller.takealot.com/api/seller-api' headers = { 'Authorization': secrets.API_KEY } r = requests.get(url1, headers=headers) myJson = r.json() print(myJson) I am getting the following error message: Traceback (most recent call last): File "C:\Users\Netchoice\PycharmProjects\pythonProject21\venv\lib\site-packages\requests\models.py", line 910, in json return complexjson.loads(self.text, **kwargs) File "C:\Program Files\Python39\lib\json\__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Program Files\Python39\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Program Files\Python39\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\Netchoice\PycharmProjects\pythonProject21\main.py", line 12, in <module> myJson = r.json() File "C:\Users\Netchoice\PycharmProjects\pythonProject21\venv\lib\site-packages\requests\models.py", line 917, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: [Errno Expecting value] <!DOCTYPE html> <html lang="en"> <head> <title>Seller Portal</title> <base href="/" /> <script> (function(h,o,t,j,a,r){ h.hj=h.hj||function(){ (h.hj.q=h.hj.q||[]).push(arguments) }; h._hjSettings={hjid:2533456,hjsv:6}; a=o.getElementsByTagName('head')[0]; r=o.createElement('script');r.async=1; r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv; a.appendChild(r); })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv='); </script> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-N55WJV4'); </script> <script> window.onerror = function(error) { if (/syntax ?error/i.test(error)) { document.querySelector('.global-error').style.display = 'block'; document.querySelector('#app').style.display = 'none'; } } </script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/react-modern-calendar-datepicker#3.1.6/lib/DatePicker.css" /> <style> .global-error { max-width: 800px; margin: 20vh auto; text-align: center; color: silver; display: none; } .global-error > button { font-family: 'Lato', 'Helvetica Neue', Arial, Helvetica, sans-serif; padding: 0.78571429em 2.5em 0.78571429em; border-radius: 0.28571429rem; font-size: 1rem; font-weight: bold; background-color: #DB2828; color: #FFFFFF; width: 100%; } </style> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <meta name="keywords" content="Takealot Seller Portal" /> <meta name="description" content="Takealot Seller Portal" /> <meta name="subject" content="ecommerce" /> <meta name="copyright" content="Takealot Online (RF) (Pty) Ltd" /> <meta name="language" content="EN" /> <meta name="robots" content="index,follow" /> <meta name="summary" content="Takealot Seller Portal for Marketplace Sellers" /> <meta name="author" content="Takelaot holdings" /> <meta name="reply-to" content="mp-dev#takealot.com" /> <meta name="owner" content="Takealot Holdings" /> <meta name="url" content="http://seller.takealot.com" /> <meta name="identifier-URL" content="http://seller.takealot.com" /> <meta name="pagename" content="Seller Portal" /> <meta name="category" content="ecommerce" /> <meta name="coverage" content="Worldwide" /> <meta name="distribution" content="Global" /> <meta name="rating" content="General" /> <meta name="revisit-after" content="7 days" /> <meta name="target" content="all" /> <meta http-equiv="Expires" content="0" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Cache-Control" content="no-cache" /> <meta http-equiv="x-dns-prefetch-control" content="off" /> <meta itemprop="name" content="Takealot Seller Portal" /> <meta itemprop="short_name" content="Takealot" /> <meta itemprop="description" content="Takealot Seller's Portal for resellers in marketplace" /> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <meta name="apple-mobile-web-app-title" content="sellers-platform-ui"> <meta name="mobile-web-app-capable" content="yes"> <meta name="theme-color" content="#fff"> <meta name="application-name" content="sellers-platform-ui"> <link rel="shortcut icon" href="icons/favicon.ico"> <link rel="apple-touch-icon" sizes="57x57" href="icons/apple-touch-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="icons/apple-touch-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="icons/apple-touch-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="icons/apple-touch-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="icons/apple-touch-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="icons/apple-touch-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="icons/apple-touch-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="icons/apple-touch-icon-152x152.png"> <link rel="apple-touch-icon" sizes="180x180" href="icons/apple-touch-icon-180x180.png"> <link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png"> <link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)" href="icons/apple-touch-startup-image-320x460.png"> <link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)" href="icons/apple-touch-startup-image-640x920.png"> <link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)" href="icons/apple-touch-startup-image-640x1096.png"> <link rel="apple-touch-startup-image" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)" href="icons/apple-touch-startup-image-750x1294.png"> <link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 3)" href="icons/apple-touch-startup-image-1182x2208.png"> <link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 3)" href="icons/apple-touch-startup-image-1242x2148.png"> <link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 1)" href="icons/apple-touch-startup-image-748x1024.png"> <link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 1)" href="icons/apple-touch-startup-image-768x1004.png"> <link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)" href="icons/apple-touch-startup-image-1496x2048.png"> <link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)" href="icons/apple-touch-startup-image-1536x2008.png"> <link href="main.css?v=7de3627337e960bb10de5aee0d428219" rel="stylesheet"></head> <body> <div class="global-error"> <img alt="error image" src="https://www.takealot.com/static/images/react-error.png" /> <br /> <button onclick="javascript:window.location.reload(true)">Click to refresh page</button> </div> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-N55WJV4" height="0" width="0" style="display:none;visibility:hidden"></iframe> </noscript> <div id="app"></div> <noscript>Javascript is required, please enable and refresh page</noscript> <script type="text/javascript" src="seller.f1604e4f8c138e7972dc.js"></script></body> <footer> <script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script> <script> (function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f); })(window, document, 'script', 'dataLayer', 'GTM-PF9XJL') </script> <noscript> <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PF9XJL" height="0" width="0" style="display:none;visibility:hidden"></iframe> </noscript> <script> window._wfx_settings = { "ent_id": "86b5bfb0-3c26-11e5-b8d9-448a5b5dd5b8" }; </script> <script async type="text/javascript" src="https://cdn.whatfix.com/prod/86b5bfb0-3c26-11e5-b8d9-448a5b5dd5b8/embed/embed.nocache.js"></script> </footer> </html> : 0 Process finished with exit code 1
The API docs you quote suggest that the API key you're sending in your header should have a prefix of Key before the actual key itself. Try: headers = { 'Authorization': f'Key {secrets.API_KEY}' }
Wait element to be present with selenium on scores website
I want to scrape this page https://www.sofascore.com/betting-tips-today I created code with selenium but don't work: from bs4 import BeautifulSoup import time from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC driver = webdriver.Chrome(executable_path=r"C:/chromedriver.exe") #, options=options) url = "https://www.sofascore.com/betting-tips-today" driver.get(url) WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.CSS_SELECTOR,'.fsFjfS'))) #wait until the element be present time.sleep(5) soup = BeautifulSoup(driver.page_source, 'html.parser') It return this error: raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: I tried without Wait but don't return anything.
You were close enough. Instead of presence_of_element_located() you need to induce WebDriverWait for the visibility_of_element_located() of a visible element and you can use the following Locator Strategy: Code Block: driver.get("https://www.sofascore.com/betting-tips-today") WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div[class^='Content__PageContainer-sc-']"))) soup = BeautifulSoup(driver.page_source, 'html.parser') print(soup) Note: You have to add the following imports : from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC Console Output: <html data-triggered="true" lang="en"> <head> <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport" /> <meta content="#0057a3" name="theme-color" /> <link href="/static/favicon.ico" rel="icon" /> <meta content="SofaScore.com LiveScore" name="author" /> <meta content="app-id=1176147574/" name="apple-itunes-app" /> <meta content="53e30a9a6b4c2d9e" name="yandex-verification" /> <link href="https://api.sofascore.com" rel="preconnect dns-prefetch" /> <link href="https://fonts.googleapis.com" rel="preconnect dns-prefetch" /> <link href="https://fonts.gstatic.com" rel="preconnect dns-prefetch" /> <link href="https://www.googletagmanager.com" rel="preconnect dns-prefetch" /> <link href="https://securepubads.g.doubleclick.net" rel="preconnect dns-prefetch" /> <link href="https://polyfill.io" rel="preconnect dns-prefetch" /> <link href="/static/manifest.json" rel="manifest" /> <link href="/static/favicon.ico" rel="shortcut icon" /> <link href="/static/favicon.ico" rel="mask-icon" /> <link href="/static/images/apple-icon-180x180.png" rel="apple-touch-icon-precomposed" sizes="180x180" /> <link href="/static/images/apple-icon-152x152.png" rel="apple-touch-icon-precomposed" sizes="152x152" /> <link href="/static/images/apple-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144" /> <link href="/static/images/apple-icon-120x120.png" rel="apple-touch-icon-precomposed" sizes="120x120" /> <link href="/static/images/apple-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114" /> <link href="/static/images/apple-icon-76x76.png" rel="apple-touch-icon-precomposed" sizes="76x76" /> <link href="/static/images/apple-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72" /> <link href="/static/images/apple-icon-57x57.png" rel="apple-touch-icon-precomposed" /> <script async="" src="https://www.googletagmanager.com/gtag/js?id=G-HNQ9P9MGZR&l=dataLayer&cx=c" type="text/javascript"></script> <script async="" src="https://www.google-analytics.com/analytics.js" type="text/javascript"></script> <script async="" src="https://www.google-analytics.com/gtm/js?id=GTM-M8Z5Q48&t=gtm5&cid=640338494.1613564014&aip=true" type="text/javascript"></script> <script async="" src="https://www.google-analytics.com/analytics.js" type="text/javascript"></script> <script async="" src="https://connect.facebook.net/signals/config/759407694841706?v=2.9.33&r=stable"></script> <script async="" src="https://connect.facebook.net/en_US/fbevents.js"></script> <script async="" crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js?hash=434141e6be23d41ce5b145e37bc66356&ua=modern_es6"></script> <script async="" src="https://www.googletagmanager.com/gtm.js?id=GTM-54Q2FDL"></script> <script charset="UTF-8" data-document-language="true" data-domain-script="bbfc9ddf-194b-411a-8caa-3d06175a3e3e" src="https://cookie-cdn.cookiepro.com/scripttemplates/otSDKStub.js" type="text/javascript"></script> <script type="text/javascript"> function OptanonWrapper() {} </script> <script> window.dataLayer = window.dataLayer || []; (function(w, d, s, l, i) { w[l] = w[l] || [] w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' }) var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '' j.async = true j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl f.parentNode.insertBefore(j, f) })(window, document, 'script', 'dataLayer', 'GTM-54Q2FDL') function gtag() { window.dataLayer.push(arguments) } </script><noscript><iframe height="0" src="https://www.googletagmanager.com/ns.html?id=GTM-54Q2FDL" style="display:none;visibility:hidden" width="0"></iframe></noscript> <script defer="" src="/static/scripts/isMobileDevice.js"></script> <script defer="" src="/static/scripts/deferredStyles.js"></script>
Website blocking Selenium : is there a way to bypass?
This webpage opens fine manually, but directly goes to a "maintenance" error message when using Selenium ! from selenium import webdriver driver = webdriver.Chrome(executable_path="chromedriver") driver.get("https://www.winamax.fr/paris-sportifs/") Is there a way to avoid this behaviour ?
Sometimes the websites checks your user-agent. Maybe you can change that. Otherwise, I would recommend using Auto-It to do the job. You could also try loading in your personal Chrome profile into Selenium.
A bit unclear why you felt website blocking Selenium. However I was able to access the website following the solution below: Code Block: from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC options = webdriver.ChromeOptions() options.add_argument("start-maximized") options.add_experimental_option("excludeSwitches", ["enable-automation"]) options.add_experimental_option('useAutomationExtension', False) driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe') driver.get('https://www.winamax.fr/paris-sportifs/') WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "section#above-content a[href='/paris-sportifs']"))) print(driver.page_source) Console Output: <html class="app-desktop js flexbox canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths pointerevents cssremunit" lang="fr" style=""><!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--><!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--><!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--><!--[if gt IE 8]><!--><!--<![endif]--><head> <title>Paris Sportifs - Parier en ligne avec Winamax</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=1024"> <meta name="verify-v1" content="divGwlYLgkmoS558zISY8BYg1KLLvQLFmRf0CmPJ1kc="> <meta name="google-site-verification" content="DB-aVdWJ00FHClrX_fsXFGgZzaYUKGVcvY7uSfOkXsw"> <meta name="format-detection" content="telephone=no"> <meta name="apple-mobile-web-app-title" content="Winamax"> <meta property="og:description" content="Agréé par l’Arjel – Pariez sur le sport sur Winamax! Faites un premier dépôt et votre premier pari sera remboursé si il est perdant."> <meta property="og:image" content="https://operator-front-static-cdn.winamax.fr/img/content/betting/ParisSportif_Facebook.jpg?v=20150401"> <meta property="fb:admins" content="519584907"> <meta property="og:site_name" content="Winamax.fr"> <meta property="og:type" content="game"> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="#WinamaxSport"> <meta name="twitter:title" content="Paris Sportifs - Parier en ligne avec Winamax"> <meta name="twitter:description" content="Agréé par l’Arjel – Pariez sur le sport sur Winamax! Faites un premier dépôt et votre premier pari sera remboursé si il est perdant."> <meta name="twitter:image:src" content="https://operator-front-static-cdn.winamax.fr/img/content/betting/ParisSportif_Facebook_twitter.jpg?v=20150401"> <meta name="twitter:domain" content="winamax.fr"> <meta property="og:url" content="https://www.winamax.fr/paris-sportifs/"> <link rel="stylesheet" id="normalize" href="https://operator-front-static-cdn.winamax.fr/style/v2/normalize.css?v=20191219-1" type="text/css" media="all"> <link rel="stylesheet" id="reset" href="https://operator-front-static-cdn.winamax.fr/style/v2/reset.css?v=20191219-1" type="text/css" media="all"> <link rel="stylesheet" id="fontawesome" href="https://operator-front-static-cdn.winamax.fr/style/v2/fontawesome.min.css?v=20191219-1" type="text/css" media="all"> <link rel="stylesheet" id="magnific-popup" href="https://operator-front-static-cdn.winamax.fr/style/v2/magnific-popup.css?v=20191219-1" type="text/css" media="all"> <link rel="stylesheet" id="spritesheet" href="https://operator-front-static-cdn.winamax.fr/style/v2/spritesheet.css?v=20191219-1" type="text/css" media="all"> <link rel="stylesheet" id="common" href="https://operator-front-static-cdn.winamax.fr/style/v2/common.css?v=20191219-1" type="text/css" media="all"> <link rel="stylesheet" id="fancybox" href="https://operator-front-static-cdn.winamax.fr/style/v2/jquery.fancybox.css?v=20191219-1" type="text/css" media="all"> <link rel="stylesheet" id="doubleslider" href="https://operator-front-static-cdn.winamax.fr/style/v2/doubleslider.css?v=20191219-1" type="text/css" media="all"> <link rel="stylesheet" id="source-sans-pro" href="https://operator-front-static-cdn.winamax.fr/style/fonts/SourceSansPro/source-sans-pro.css?v=20191219-1" type="text/css" media="all"> <link rel="icon" href="https://operator-front-static-cdn.winamax.fr/img/style/v2/favicon.ico" type="image/png"> <link rel="manifest" href="/manifest.json"> <link rel="apple-touch-icon" href="https://operator-front-static-cdn.winamax.fr/img/style/v2/20170721_touch_icon_winamax.png"> <link rel="canonical" href="https://www.winamax.fr/paris-sportifs/"> <link rel="alternate" hreflang="fr" href="https://www.winamax.fr/paris-sportifs/"> <link rel="alternate" hreflang="en" href="https://www.winamax.fr/en/sports-betting/"> <link rel="alternate" hreflang="de" href="https://www.winamax.fr/de/sportwetten/"> <script async="" src="https://www.google-analytics.com/analytics.js"></script><script type="text/javascript" async="" src="https://ssl.google-analytics.com/ga.js"></script><script type="text/javascript" src="https://operator-front-static-cdn.winamax.fr/script/swfobject.js?v=20191219-1"></script> <script type="text/javascript" src="https://operator-front-static-cdn.winamax.fr/script/v2/betting-helpers.js?v=20191219-1"></script> <script type="text/javascript" src="https://operator-front-static-cdn.winamax.fr/script/numeral.js?v=20191219-1"></script> <script type="text/javascript" src="https://operator-front-static-cdn.winamax.fr/script/numeral.languages.js?v=20191219-1"></script> <script src="https://operator-front-static-cdn.winamax.fr/script/v2/lib/modernizr.custom.js?v=20191219-1"></script> <!--[if lte IE 8]> <script src="https://operator-front-static-cdn.winamax.fr/script/v2/lib/jquery-1.10.1.min.js?v=20191219-1"></script> <script src="https://operator-front-static-cdn.winamax.fr/script/v2/lib/selectivizr-min.js?v=20191219-1"></script> <![endif]--> <script language="Javascript" type="text/javascript" src="https://operator-front-static-cdn.winamax.fr/script/messages/messages_fr.js?v=20191219-1"></script> <script> var $siteLanguage = 'FR'; var $siteLanguagePath = ''; var $siteLicense = 'FR'; </script> <style data-styled-components=""></style><script charset="utf-8" src="https://operator-front-static-cdn.winamax.fr/betting/client/1.55.1/main.30da6bcf4d935f4ad03c.js"></script><script charset="utf-8" src="https://operator-front-static-cdn.winamax.fr/betting/client/1.55.1/main.6dcf45fd436abb91aedd.js"></script><script charset="utf-8" src="https://operator-front-static-cdn.winamax.fr/betting/client/1.55.1/main.1812cb976eb7abff1666.js"></script><script charset="utf-8" src="https://operator-front-static-cdn.winamax.fr/betting/client/1.55.1/main.fbe533b04c719597d791.js"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="jquery" src="https://operator-front-static-cdn.winamax.fr/script/v2/lib/jquery-1.12.4.min.js?v=20191219-1"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="swipe" src="https://operator-front-static-cdn.winamax.fr/script/v2/lib/swipe.js?v=20191219-1"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="touch" src="https://operator-front-static-cdn.winamax.fr/script/v2/lib/jquery.touch.js?v=20191219-1"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="magnific" src="https://operator-front-static-cdn.winamax.fr/script/v2/lib/jquery.magnific-popup.min.js?v=20191219-1"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="fancybox" src="https://operator-front-static-cdn.winamax.fr/script/v2/lib/jquery.fancybox.pack.js?v=20191219-1"></script><style id="detectElementResize" type="text/css">#keyframes resizeanim { from { opacity: 0; } to { opacity: 0; } } .resize-triggers { animation: 1ms resizeanim; visibility: hidden; opacity: 0; } .resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }</style><style type="text/css">.fancybox-margin{margin-right:17px;}</style><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="script/v2/common" src="https://operator-front-static-cdn.winamax.fr/script/v2/common.js?v=20191219-1"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="script/v2/mobile" src="https://operator-front-static-cdn.winamax.fr/script/v2/mobile.js?v=20191219-1"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="script/v2/gallery" src="https://operator-front-static-cdn.winamax.fr/script/v2/gallery.js?v=20191219-1"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="script/v2/doubleslider" src="https://operator-front-static-cdn.winamax.fr/script/v2/doubleslider.js?v=20191219-1"></script></head> <body class="lang-fr license-fr"> <div id="wrap-menu-overlay"></div> <!-- Facebook --> <div id="fb-root"></div> <script>$fbLocalized = 'fr_FR';</script> <div id="doc"> <div id="inner-wrap"><div style="cursor: pointer; background: url("https://static.winamax.fr/img/style/v2/common/avertissement.png?v=2") center center no-repeat rgb(0, 0, 0); height: 60px; z-index: 112; display: block;"></div> <script> var arjelBannerImgPath = Math.random() > 0.5 ? "https://static.winamax.fr/img/style/v2/common/avertissement.png?v=2" : "https://static.winamax.fr/img/style/v2/common/avertissement-alt.png"; function setupArjelBanner() { var ref = document.getElementById("inner-wrap"); if (ref) { var banner = document.createElement("div"); banner.style.cursor = "pointer"; banner.style.background = "url('" + arjelBannerImgPath + "') no-repeat center center #000"; banner.style.height = "60px"; banner.style.zIndex = Math.floor(50 + Math.random() * 100); function goArjelInfos() { window.open("https://www.winamax.fr/CLIC/PREVENTION/JIS_HOME/www.joueurs-info-service.fr"); } function WidthChange(mq) { if (mq.matches) { var arjelBannerImgPath = Math.random() > 0.5 ? "https://static.winamax.fr/img/style/v2/common/avertissement-mobile.png?v=2" : "https://static.winamax.fr/img/style/v2/common/avertissement-alt-mobile.png"; banner.style.background = "url('" + arjelBannerImgPath + "') no-repeat center center #000"; banner.style.backgroundSize = "100% auto"; } else { banner.style.display = "block"; } } banner.addEventListener("click", goArjelInfos, false); ref.insertBefore(banner, ref.firstChild); if (matchMedia) { var mq = window.matchMedia("(max-width: 480px)"); mq.addListener(WidthChange); WidthChange(mq); } } } setupArjelBanner(); </script> <div class="top-notif-wrapper"><div class="notification top-notif medium cookie-consent"> <i class="icon-warning-sign"></i> <p><span>En poursuivant votre navigation sur ce site, vous acceptez l’utilisation de Cookies afin de réaliser des statistiques de visites et vous proposer des promotions adaptées. S’y opposer - Plus d’informations sur les cookies</span></p> <i class="icon-remove"></i></div> </div><header id="masthead"> <div class="container"> <a href="/" id="logo"> <img src="https://operator-front-static-cdn.winamax.fr/img/style/v2/common/logo.png" alt="Winamax"> <img class="hover" src="https://operator-front-static-cdn.winamax.fr/img/style/v2/common/logo-highlight.png" alt=""> </a> <div class="content"> <div id="login-toggle" class="toggle"> <a href="/account/login.php?redir=/paris-sportifs/"> <svg id="user-icon" viewBox="0 0 32 24"> <path d="M10.3,13.9c0,0-7.1-0.1-9.8,5.3v4.7h9.8h9.8v-4.7C17.5,13.8,10.3,13.9,10.3,13.9z"></path> <ellipse cx="10.3" cy="6.4" rx="4.9" ry="6.2"></ellipse> </svg> </a> </div> <div id="login-container" class="expandable"> Se connecter S'inscrire <div id="login-popup"> <form id="login-form" method="post" action="/paris-sportifs/" autocomplete="off"> <p class="field"> <label>Adresse email</label> <input type="email" name="email" id="loginbox_email" placeholder="vous#exemple.com" tabindex="1" autocomplete="off" value=""> </p> <p class="field"> <label>Mot de passe</label> <input type="password" id="loginbox_password" name="password" placeholder="" tabindex="2" autocomplete="off"> <a class="forgot-password" href="/account/lost_password.php">Mot de passe oublié ?</a> </p> <p class="field birthdate"> <label for="day-input">Date de naissance</label> <input type="text" id="loginbox_birthday" name="birth_day" autocomplete="off" placeholder="JJ" tabindex="3" pattern="[0-9]*" size="2" maxlength="2" value=""> <input type="text" id="loginbox_birthmonth" name="birth_month" autocomplete="off" placeholder="MM" tabindex="4" pattern="[0-9]*" size="2" maxlength="2" value=""> <input type="text" id="loginbox_birthyear" name="birth_year" autocomplete="off" placeholder="AAAA" tabindex="5" pattern="[0-9]*" size="4" maxlength="4" value=""> </p> <button type="submit" id="login-button" name="submitlogin" class="secondary-button" tabindex="6"><i class="icon-lock"></i>Connexion</button> </form> <div id="no-account"> <span>Pas encore de compte ?</span> Inscrivez-vous gratuitement </div> </div> <div id="pin-popup"> </div> </div> <div id="search" class="expandable" style="height:28px"> </div> <div id="nav-toggle" class="toggle"> <svg id="list-icon" viewBox="0 0 24 24"> <rect x="6" y="17" width="18" height="3"></rect> <rect x="6" y="10.5" width="18" height="3"></rect> <rect x="6" y="4" width="18" height="3"></rect> <rect x="0" y="4" width="3" height="3"></rect> <rect x="0" y="10.5" width="3" height="3"></rect> <rect x="0" y="17" width="3" height="3"></rect> </svg> </div> </div> </div> <nav id="main-nav" class=""> <ul class="main-nav-list"> <li class=""> JOUER AU POKER </li> <li class="focus"> PARIS SPORTIFS </li> <li class=""> GRILLES </li> <li class=""> JEU DE L’ENTRAINEUR </li> <li class=""> PROMOS </li> <li class=""> VIP </li> <li class=""> ACTUS </li> </ul> </nav> </header> <section id="above-content"> <nav id="secondary-nav" class="container"> <div id="section-title"> Paris Sportifs </div> <ul> <li>À la Une</li> <li>LIVE</li> <li>Multiplex</li> <li>Winamax TV</li> <li>Calendrier</li> <li>Mes paris</li> <li>Stats</li> <li>Résultats</li> </ul> </nav> </section>
How to get image url from telegram post with python
Is there any way to get direct image URL from http-link to telegram post with Python? I have direct link to telegramm post, example: https://t.me/tele2slack/223 I can find image URL with chrome inspector ... for my link image url is: image https://cdn4.telesco.pe/file/oxrpfWsqyBeFI3KIxPqBf-5A1k_OEiueCdwpuhR0oWtM7_88zpYi7kRsADHYobpByICSfImn_CffaxWr2nC6E49BSFchpKRKO5bkNPsFmefhsjdLstZwtHaeZGqHkqWFcGbtujPcmigwJkl7gH7tjHJrqlpmhZmGS7QnacF8PNxpocVMqaQXRxLW7kAwm6lVxLYo6AJqNb8bdZ5RXJgd6mQG0v5QINvTwtJNdioEWDAjtsufsxHVgzdUK1yBn1M3cjmhjfv8o4uMyi0bhsdFV_q21e0Sqj-QvUi-99JCPSHNVlLBfoWQEtSCeErPE45UrlqbnELYOznvLq_CeE6BcQ.jpg Is there any way to automate this process with python? I've tried GET request, but unfortunatelly get no useful information: response = requests.get("https://t.me/tele2slack/223") response: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Telegram: Contact #tele2slack</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta property="og:title" content="Tele2slack_dev"> <meta property="og:image" content="https://telegram.org/img/t_logo.png"> <meta property="og:site_name" content="Telegram"> <meta property="og:description" content="🇺🇸#TSN #отчетности #сша Tyson Foods Q4 Earnings: -Q4 Adj EPS $1.21 (est $1.25) -Q4 Revenue $10.88 Bln (esat $11.0 Bln)"> <meta property="twitter:title" content="Tele2slack_dev"> <meta property="twitter:image" content="https://telegram.org/img/t_logo.png"> <meta property="twitter:site" content="#Telegram"> <meta property="al:ios:app_store_id" content="686449807"> <meta property="al:ios:app_name" content="Telegram Messenger"> <meta property="al:ios:url" content="tg://resolve?domain=tele2slack&post=224"> <meta property="al:android:url" content="tg://resolve?domain=tele2slack&post=224"> <meta property="al:android:app_name" content="Telegram"> <meta property="al:android:package" content="org.telegram.messenger"> <meta name="twitter:card" content="summary"> <meta name="twitter:site" content="#Telegram"> <meta name="twitter:description" content="🇺🇸#TSN #отчетности #сша Tyson Foods Q4 Earnings: -Q4 Adj EPS $1.21 (est $1.25) -Q4 Revenue $10.88 Bln (esat $11.0 Bln) "> <meta name="twitter:app:name:iphone" content="Telegram Messenger"> <meta name="twitter:app:id:iphone" content="686449807"> <meta name="twitter:app:url:iphone" content="tg://resolve?domain=tele2slack&post=224"> <meta name="twitter:app:name:ipad" content="Telegram Messenger"> <meta name="twitter:app:id:ipad" content="686449807"> <meta name="twitter:app:url:ipad" content="tg://resolve?domain=tele2slack&post=224"> <meta name="twitter:app:name:googleplay" content="Telegram"> <meta name="twitter:app:id:googleplay" content="org.telegram.messenger"> <meta name="twitter:app:url:googleplay" content="https://t.me/tele2slack/224"> <meta name="apple-itunes-app" content="app-id=686449807, app-argument: tg://resolve?domain=tele2slack&post=224"> <link rel="shortcut icon" href="//telegram.org/favicon.ico?3" type="image/x-icon" /> <link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet" type="text/css"> <!--link href="/css/myriad.css" rel="stylesheet"--> <link href="//telegram.org/css/bootstrap.min.css?3" rel="stylesheet"> <link href="//telegram.org/css/telegram.css?177" rel="stylesheet" media="screen"> </head> <body> <div class="tgme_page_wrap"> <div class="tgme_head_wrap"> <div class="tgme_head"> <a href="//telegram.org/" class="tgme_head_brand"> <i class="tgme_logo"></i> </a> </div> </div> <a class="tgme_head_dl_button" href="//telegram.org/dl?tme=6dae9c11480edfa67e_2093069837989679044"> Don't have <strong>Telegram</strong> yet? Try it now!<i class="tgme_icon_arrow"></i> </a> <div class="tgme_page tgme_page_post"> <div class="tgme_page_widget" id="widget"> <script async src="https://telegram.org/js/telegram-widget.js?7" data-telegram-post="tele2slack/224" data-width="100%"></script> </div> <div class="tgme_page_widget_actions" id="widget_actions"> <div class="tgme_page_widget_actions_cont"> <div class="tgme_page_widget_action_right"> <div class="tgme_page_context_btn"><a class="tgme_action_button_new" href="/s/tele2slack/224"><span class="tgme_action_button_label">Context</span></a></div> </div> <div class="tgme_page_widget_action_left"> <div class="tgme_page_embed_btn"> <a class="tgme_action_button_new" onclick="return toggleEmbed();"><span class="tgme_action_button_label">Embed</span></a> </div> </div> <div class="tgme_page_widget_action"> <a class="tgme_action_button_new" href="tg://resolve?domain=tele2slack&post=224">View In Channel</a> </div> <div class="tgme_page_embed_action"> <textarea class="tgme_page_embed_code" rows="3" id="embed_code_field" readonly><script async src="https://telegram.org/js/telegram-widget.js?7" data-telegram-post="tele2slack/224" data-width="100%"></script></textarea> <div class="tgme_page_copy_action"> <a class="tgme_action_button_new" onclick="return copyEmbedCode();">Copy</a> </div> </div> </div> </div> </div> </div> <div id="tgme_frame_cont"></div> <script type="text/javascript"> var protoUrl = "tg:\/\/resolve?domain=tele2slack&post=224"; if (false) { var iframeContEl = document.getElementById('tgme_frame_cont') || document.body; var iframeEl = document.createElement('iframe'); iframeContEl.appendChild(iframeEl); var pageHidden = false; window.addEventListener('pagehide', function () { pageHidden = true; }, false); window.addEventListener('blur', function () { pageHidden = true; }, false); if (iframeEl !== null) { iframeEl.src = protoUrl; } !false && setTimeout(function() { if (!pageHidden) { window.location = protoUrl; } }, 2000); } else if (protoUrl) { setTimeout(function() { window.location = protoUrl; }, 100); } </script> <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-45099287-3', 'auto', {'sampleRate': 5}); ga('set', 'anonymizeIp', true); ga('send', 'pageview');function toggleEmbed() { var widget_actions = document.getElementById('widget_actions'); if (widget_actions.classList.contains('embed_opened')) { widget_actions.classList.remove('embed_opened'); } else { widget_actions.classList.add('embed_opened'); if (!document.body.classList.contains('fixed_actions')) { window.scrollTo(0, document.body.offsetHeight); } selectEmbedCode(); } checkActionsPosition(); return false; } function selectEmbedCode() { var field = document.getElementById('embed_code_field'); field.focus(); field.setSelectionRange(0, field.value.length); } function copyEmbedCode() { selectEmbedCode(); document.execCommand('copy'); return false; } function checkActionsPosition() { var widget = document.getElementById('widget'); var widget_actions = document.getElementById('widget_actions'); var widget_rect = widget.getBoundingClientRect(); var actions_bottom = widget_rect.bottom + widget_actions.offsetHeight - 1; var client_bottom = window.innerHeight || html.clientHeight; if (actions_bottom > client_bottom) { widget.style.marginBottom = widget_actions.offsetHeight + 'px'; document.body.classList.add('fixed_actions'); } else { widget.style.marginBottom = ''; document.body.classList.remove('fixed_actions'); } } function postMessageHandler(event) { try { var data = JSON.parse(event.data); } catch(e) { var data = {}; } if (data.event == 'resize') { setTimeout(checkActionsPosition, 50); } } window.addEventListener('resize', checkActionsPosition); window.addEventListener('scroll', checkActionsPosition); window.addEventListener('message', postMessageHandler); </script> </body> </html> <!-- page generated in 10.93ms -->
Usually i use selenium to make web scraping and other automations. Check this solution, maybe this could help: import urllib from selenium import webdriver driver = webdriver.chrome() driver.get('https://www.google.com/') # get the image from google website img = driver.find_element_by_xpath('//*[#id="hplogo"]/img') src = img.get_attribute('src') # download the image urllib.urlretrieve(src, "google_logo.png") driver.close() To get the xpath source, RIGHT BUTTON MOUSE> INSPECT ELEMENT > RIGHT CLICK ON HTML ELEMENT> CLICK COPY XPATH
How to make Python selenium chromedriver load all the elements in a webpage?
When browsing this web site by Chrome, it will show all the prices When using Python Webdriver chromedrive, it stop in the middle, cannot show the price detail. Just like below: What I miss? import os from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument("--headless") base_url = "https://booking.hkexpress.com/en-US/select/?SearchType=RETURN&OriginStation=HKG&DestinationStation=KIX&DepartureDate=19/04/2019&ReturnDate=26/04/2019&Adults=1&LowFareFinderSelected=false" driver = webdriver.Chrome(executable_path=(r'D:\My Homepages\hkexpress\chromedriver.exe'), chrome_options=chrome_options) driver.get(base_url + '/') pageSource = driver.page_source print(pageSource) driver.save_screenshot('screen.png') driver.close()
Seems you were pretty close. As the website is based on JavaScript so you have to induce WebDriverWait for the elements to be visible and you can use the following solution: Code Block: # -*- coding: UTF-8 -*- from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC options = webdriver.ChromeOptions() options.add_argument("start-maximized") options.add_argument("--disable-extensions") # options.add_argument('disable-infobars') driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe') driver.get("https://booking.hkexpress.com/en-US/select/?SearchType=RETURN&OriginStation=HKG&DestinationStation=KIX&DepartureDate=19/04/2019&ReturnDate=26/04/2019&Adults=1&LowFareFinderSelected=false") WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//h2[#class='label' and normalize-space()='Departure']"))) print(driver.page_source) driver.save_screenshot('./Screenshots/screen.png') driver.quit() Console Output: <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"><head> <script type="text/javascript" async="" src="https://www.google-analytics.com/plugins/ua/ec.js"></script><script type="text/javascript" async="" src="//avd.innity.com/dc/cb/?mt=_iampt._cbUC"></script><script type="text/javascript" async="" src="https://avd.innity.net/lib/dc.js"></script><script type="text/javascript" id="veConnect" async="" crossorigin="anonymous" src="https://confighk.veinteractive.com/scripts/5.0/capture-apps-5.0.0.js"></script><script type="text/javascript" src="https://bam.nr-data.net/1/4475d8487d?a=163005030&v=1118.0c07c19&to=MQBSZxECWRBRBUEMCQhKfWUgTGcCVwN2CggSF19fDwZFTHkIUQAe&rst=13575&ref=https://booking.hkexpress.com/en-US/select/&ap=8&be=3016&fe=12746&dc=9556&perf=%7B%22timing%22:%7B%22of%22:1553585880823,%22n%22:0,%22f%22:3,%22dn%22:526,%22dne%22:526,%22c%22:526,%22s%22:630,%22ce%22:932,%22rq%22:932,%22rp%22:1053,%22rpe%22:1413,%22dl%22:1061,%22di%22:5066,%22ds%22:9555,%22de%22:9558,%22dc%22:12746,%22l%22:12746,%22le%22:12776%7D,%22navigation%22:%7B%7D%7D&jsonp=NREUM.setToken"></script><script type="text/javascript" async="" src="https://www.googleadservices.com/pagead/conversion_async.js"></script><script src="https://js-agent.newrelic.com/nr-1118.min.js"></script><script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script><script type="text/javascript" src="https://static.hkexpress.com/libs/jquery3-3-1.min.js"></script> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /><script type="text/javascript">window.NREUM||(NREUM={});NREUM.info = {"beacon":"bam.nr-data.net","errorBeacon":"bam.nr-data.net","licenseKey":"4475d8487d","applicationID":"163005030","transactionName":"MQBSZxECWRBRBUEMCQhKZUEKTFINHTNmShUDCVVQF0w=","queueTime":0,"applicationTime":1,"agent":"","atts":""}</script><script type="text/javascript">window.NREUM||(NREUM={}),__nr_require=function(e,n,t){function r(t){if(!n[t]){var o=n[t]={exports:{}};e[t][0].call(o.exports,function(n){var o=e[t][1][n];return r(o||n)},o,o.exports)}return n[t].exports}if("function"==typeof __nr_require)return __nr_require;for(var o=0;o<t.length;o++)r(t[o]);return r}({1:[function(e,n,t){function r(){}function o(e,n,t){return function(){return i(e,[c.now()].concat(u(arguments)),n?null:this,t),n?void 0:this}}var i=e("handle"),a=e(3),u=e(4),f=e("ee").get("tracer"),c=e("loader"),s=NREUM;"undefined"==typeof window.newrelic&&(newrelic=s);var p=["setPageViewName","setCustomAttribute","setErrorHandler","finished","addToTrace","inlineHit","addRelease"],d="api-",l=d+"ixn-";a(p,function(e,n){s[n]=o(d+n,!0,"api")}),s.addPageAction=o(d+"addPageAction",!0),s.setCurrentRouteName=o(d+"routeName",!0),n.exports=newrelic,s.interaction=function(){return(new r).get()};var m=r.prototype={createTracer:function(e,n){var t={},r=this,o="function"==typeof n;return i(l+"tracer",[c.now(),e,t],r),function(){if(f.emit((o?"":"no-")+"fn-start",[c.now(),r,o],t),o)try{return n.apply(this,arguments)}catch(e){throw f.emit("fn-err",[arguments,this,e],t),e}finally{f.emit("fn-end",[c.now()],t)}}}};a("actionText,setName,setAttribute,save,ignore,onEnd,getContext,end,get".split(","),function(e,n){m[n]=o(l+n)}),newrelic.noticeError=function(e,n){"string"==typeof e&&(e=new Error(e)),i("err",[e,c.now(),!1,n])}},{}],2:[function(e,n,t){function r(e,n){if(!o)return!1;if(e!==o)return!1;if(!n)return!0;if(!i)return!1;for(var t=i.split("."),r=n.split("."),a=0;a<r.length;a++)if(r[a]!==t[a])return!1;return!0}var o=null,i=null,a=/Version\/(\S+)\s+Safari/;if(navigator.userAgent){var u=navigator.userAgent,f=u.match(a);f&&u.indexOf("Chrome")===-1&&u.indexOf("Chromium")===-1&&(o="Safari",i=f[1])}n.exports={agent:o,version:i,match:r}},{}],3:[function(e,n,t){function r(e,n){var t=[],r="",i=0;for(r in e)o.call(e,r)&&(t[i]=n(r,e[r]),i+=1);return t}var o=Object.prototype.hasOwnProperty;n.exports=r},{}],4:[function(e,n,t){function r(e,n,t){n||(n=0),"undefined"==typeof t&&(t=e?e.length:0);for(var r=-1,o=t-n||0,i=Array(o<0?0:o);++r<o;)i[r]=e[n+r];return i}n.exports=r},{}],5:[function(e,n,t){n.exports={exists:"undefined"!=typeof window.performance&&window.performance.timing&&"undefined"!=typeof window.performance.timing.navigationStart}},{}],ee:[function(e,n,t){function r(){}function o(e){function n(e){return e&&e instanceof r?e:e?f(e,u,i):i()}function t(t,r,o,i){if(!d.aborted||i){e&&e(t,r,o);for(var a=n(o),u=v(t),f=u.length,c=0;c<f;c++)u[c].apply(a,r);var p=s[y[t]];return p&&p.push([b,t,r,a]),a}}function l(e,n){h[e]=v(e).concat(n)}function m(e,n){var t=h[e];if(t)for(var r=0;r<t.length;r++)t[r]===n&&t.splice(r,1)}function v(e){return h[e]||[]}function g(e){return p[e]=p[e]||o(t)}function w(e,n){c(e,function(e,t){n=n||"feature",y[t]=n,n in s||(s[n]=[])})}var h={},y={},b={on:l,addEventListener:l,removeEventListener:m,emit:t,get:g,listeners:v,context:n,buffer:w,abort:a,aborted:!1};return b}function i(){return new r}function a(){(s.api||s.feature)&&(d.aborted=!0,s=d.backlog={})}var u="nr#context",f=e("gos"),c=e(3),s={},p={},d=n.exports=o();d.backlog=s},{}],gos:[function(e,n,t){function r(e,n,t){if(o.call(e,n))return e[n];var r=t();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(e,n,{value:r,writable:!0,enumerable:!1}),r}catch(i){}return e[n]=r,r}var o=Object.prototype.hasOwnProperty;n.exports=r},{}],handle:[function(e,n,t){function r(e,n,t,r){o.buffer([e],r),o.emit(e,n,t)}var o=e("ee").get("handle");n.exports=r,r.ee=o},{}],id:[function(e,n,t){function r(e){var n=typeof e;return!e||"object"!==n&&"function"!==n?-1:e===window?0:a(e,i,function(){return o++})}var o=1,i="nr#id",a=e("gos");n.exports=r},{}],loader:[function(e,n,t){function r(){if(!E++){var e=x.info=NREUM.info,n=l.getElementsByTagName("script")[0];if(setTimeout(s.abort,3e4),!(e&&e.licenseKey&&e.applicationID&&n))return s.abort();c(y,function(n,t){e[n]||(e[n]=t)}),f("mark",["onload",a()+x.offset],null,"api");var t=l.createElement("script");t.src="https://"+e.agent,n.parentNode.insertBefore(t,n)}}function o(){"complete"===l.readyState&&i()}function i(){f("mark",["domContent",a()+x.offset],null,"api")}function a(){return O.exists&&performance.now?Math.round(performance.now()):(u=Math.max((new Date).getTime(),u))-x.offset}var u=(new Date).getTime(),f=e("handle"),c=e(3),s=e("ee"),p=e(2),d=window,l=d.document,m="addEventListener",v="attachEvent",g=d.XMLHttpRequest,w=g&&g.prototype;NREUM.o={ST:setTimeout,SI:d.setImmediate,CT:clearTimeout,XHR:g,REQ:d.Request,EV:d.Event,PR:d.Promise,MO:d.MutationObserver};var h=""+location,y={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net",agent:"js-agent.newrelic.com/nr-1118.min.js"},b=g&&w&&w[m]&&!/CriOS/.test(navigator.userAgent),x=n.exports={offset:u,now:a,origin:h,features:{},xhrWrappable:b,userAgent:p};e(1),l[m]?(l[m]("DOMContentLoaded",i,!1),d[m]("load",r,!1)):(l[v]("onreadystatechange",o),d[v]("onload",r)),f("mark",["firstbyte",u],null,"api");var E=0,O=e(5)},{}]},{},["loader"]);</script><script type="text/javascript">window.NREUM||(NREUM={});NREUM.info = {"beacon":"bam.nr-data.net","errorBeacon":"bam.nr-data.net","licenseKey":"4475d8487d","applicationID":"163005030","transactionName":"MQBSZxECWRBRBUEMCQhKfWUgTGcCVwN2CggSF19fDwZFTHkIUQAe","queueTime":0,"applicationTime":8,"agent":"","atts":""}</script><script type="text/javascript">window.NREUM||(NREUM={}),__nr_require=function(e,n,t){function r(t){if(!n[t]){var o=n[t]={exports:{}};e[t][0].call(o.exports,function(n){var o=e[t][1][n];return r(o||n)},o,o.exports)}return n[t].exports}if("function"==typeof __nr_require)return __nr_require;for(var o=0;o<t.length;o++)r(t[o]);return r}({1:[function(e,n,t){function r(){}function o(e,n,t){return function(){return i(e,[c.now()].concat(u(arguments)),n?null:this,t),n?void 0:this}}var i=e("handle"),a=e(3),u=e(4),f=e("ee").get("tracer"),c=e("loader"),s=NREUM;"undefined"==typeof window.newrelic&&(newrelic=s);var p=["setPageViewName","setCustomAttribute","setErrorHandler","finished","addToTrace","inlineHit","addRelease"],d="api-",l=d+"ixn-";a(p,function(e,n){s[n]=o(d+n,!0,"api")}),s.addPageAction=o(d+"addPageAction",!0),s.setCurrentRouteName=o(d+"routeName",!0),n.exports=newrelic,s.interaction=function(){return(new r).get()};var m=r.prototype={createTracer:function(e,n){var t={},r=this,o="function"==typeof n;return i(l+"tracer",[c.now(),e,t],r),function(){if(f.emit((o?"":"no-")+"fn-start",[c.now(),r,o],t),o)try{return n.apply(this,arguments)}catch(e){throw f.emit("fn-err",[arguments,this,e],t),e}finally{f.emit("fn-end",[c.now()],t)}}}};a("actionText,setName,setAttribute,save,ignore,onEnd,getContext,end,get".split(","),function(e,n){m[n]=o(l+n)}),newrelic.noticeError=function(e,n){"string"==typeof e&&(e=new Error(e)),i("err",[e,c.now(),!1,n])}},{}],2:[function(e,n,t){function r(e,n){if(!o)return!1;if(e!==o)return!1;if(!n)return!0;if(!i)return!1;for(var t=i.split("."),r=n.split("."),a=0;a<r.length;a++)if(r[a]!==t[a])return!1;return!0}var o=null,i=null,a=/Version\/(\S+)\s+Safari/;if(navigator.userAgent){var u=navigator.userAgent,f=u.match(a);f&&u.indexOf("Chrome")===-1&&u.indexOf("Chromium")===-1&&(o="Safari",i=f[1])}n.exports={agent:o,version:i,match:r}},{}],3:[function(e,n,t){function r(e,n){var t=[],r="",i=0;for(r in e)o.call(e,r)&&(t[i]=n(r,e[r]),i+=1);return t}var o=Object.prototype.hasOwnProperty;n.exports=r},{}],4:[function(e,n,t){function r(e,n,t){n||(n=0),"undefined"==typeof t&&(t=e?e.length:0);for(var r=-1,o=t-n||0,i=Array(o<0?0:o);++r<o;)i[r]=e[n+r];return i}n.exports=r},{}],5:[function(e,n,t){n.exports={exists:"undefined"!=typeof window.performance&&window.performance.timing&&"undefined"!=typeof window.performance.timing.navigationStart}},{}],ee:[function(e,n,t){function r(){}function o(e){function n(e){return e&&e instanceof r?e:e?f(e,u,i):i()}function t(t,r,o,i){if(!d.aborted||i){e&&e(t,r,o);for(var a=n(o),u=v(t),f=u.length,c=0;c<f;c++)u[c].apply(a,r);var p=s[y[t]];return p&&p.push([b,t,r,a]),a}}function l(e,n){h[e]=v(e).concat(n)}function m(e,n){var t=h[e];if(t)for(var r=0;r<t.length;r++)t[r]===n&&t.splice(r,1)}function v(e){return h[e]||[]}function g(e){return p[e]=p[e]||o(t)}function w(e,n){c(e,function(e,t){n=n||"feature",y[t]=n,n in s||(s[n]=[])})}var h={},y={},b={on:l,addEventListener:l,removeEventListener:m,emit:t,get:g,listeners:v,context:n,buffer:w,abort:a,aborted:!1};return b}function i(){return new r}function a(){(s.api||s.feature)&&(d.aborted=!0,s=d.backlog={})}var u="nr#context",f=e("gos"),c=e(3),s={},p={},d=n.exports=o();d.backlog=s},{}],gos:[function(e,n,t){function r(e,n,t){if(o.call(e,n))return e[n];var r=t();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(e,n,{value:r,writable:!0,enumerable:!1}),r}catch(i){}return e[n]=r,r}var o=Object.prototype.hasOwnProperty;n.exports=r},{}],handle:[function(e,n,t){function r(e,n,t,r){o.buffer([e],r),o.emit(e,n,t)}var o=e("ee").get("handle");n.exports=r,r.ee=o},{}],id:[function(e,n,t){function r(e){var n=typeof e;return!e||"object"!==n&&"function"!==n?-1:e===window?0:a(e,i,function(){return o++})}var o=1,i="nr#id",a=e("gos");n.exports=r},{}],loader:[function(e,n,t){function r(){if(!E++){var e=x.info=NREUM.info,n=l.getElementsByTagName("script")[0];if(setTimeout(s.abort,3e4),!(e&&e.licenseKey&&e.applicationID&&n))return s.abort();c(y,function(n,t){e[n]||(e[n]=t)}),f("mark",["onload",a()+x.offset],null,"api");var t=l.createElement("script");t.src="https://"+e.agent,n.parentNode.insertBefore(t,n)}}function o(){"complete"===l.readyState&&i()}function i(){f("mark",["domContent",a()+x.offset],null,"api")}function a(){return O.exists&&performance.now?Math.round(performance.now()):(u=Math.max((new Date).getTime(),u))-x.offset}var u=(new Date).getTime(),f=e("handle"),c=e(3),s=e("ee"),p=e(2),d=window,l=d.document,m="addEventListener",v="attachEvent",g=d.XMLHttpRequest,w=g&&g.prototype;NREUM.o={ST:setTimeout,SI:d.setImmediate,CT:clearTimeout,XHR:g,REQ:d.Request,EV:d.Event,PR:d.Promise,MO:d.MutationObserver};var h=""+location,y={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net",agent:"js-agent.newrelic.com/nr-1118.min.js"},b=g&&w&&w[m]&&!/CriOS/.test(navigator.userAgent),x=n.exports={offset:u,now:a,origin:h,features:{},xhrWrappable:b,userAgent:p};e(1),l[m]?(l[m]("DOMContentLoaded",i,!1),d[m]("load",r,!1)):(l[v]("onreadystatechange",o),d[v]("onload",r)),f("mark",["firstbyte",u],null,"api");var E=0,O=e(5)},{}]},{},["loader"]);</script> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta property="og:title" content="HK Express - Cheap Flights To & from Hong Kong | Budget Airline in Asia" /> <meta property="og:description" content="HK Express: Hong Kong's first and only low-fare airline! View and book airfare tickets in Asia, check flight schedules & flight status." /> <meta property="og:url" content="https://www.hkexpress.com" /> <meta property="og:image" content="https://static.hkexpress.com/media/1068/our-story.jpg?cropmode=percentaje&width=480" /> <meta name="twitter:card" content="summary" /> <meta name="twitter:title" content="HK Express - Cheap Flights To & from Hong Kong | Budget Airline in Asia" /> <meta name="twitter:description" content="HK Express: Hong Kong's first and only low-fare airline! View and book airfare tickets in Asia, check flight schedules & flight status." /> <meta name="twitter:url" content="https://www.hkexpress.com" /> <meta name="twitter:image" content="https://static.hkexpress.com/media/1068/our-story.jpg?cropmode=percentaje&width=480" /> <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="0" /> <base href="/" /> <meta name="author" content="" /> <meta name="description" content="" /> <link rel="canonical" href="https://www.hkexpress.com/en-us/select/" /> <link rel="alternate" href="https://www.hkexpress.com/en-hk/select/" hreflang="en" /> <link rel="alternate" href="https://www.hkexpress.com/zh-hk/select/" hreflang="zh" /> <link rel="alternate" href="https://www.hkexpress.com/zh-cn/select/" hreflang="zh-CN" /> <link rel="alternate" href="https://www.hkexpress.com/zh-tw/select/" hreflang="zh-TW" /> <link rel="alternate" href="https://www.hkexpress.com/ja/select/" hreflang="ja" /> <link rel="alternate" href="https://www.hkexpress.com/ko/select/" hreflang="ko" /> <link rel="alternate" href="https://www.hkexpress.com/en-kh/select/" hreflang="en-kh" /> <link rel="alternate" href="https://www.hkexpress.com/en-th/select/" hreflang="en-th" /> <link rel="alternate" href="https://www.hkexpress.com/en-vn/select/" hreflang="en-vn" /> <link rel="apple-touch-icon" sizes="180x180" href="../../App_plugins/IBE/assets/imgs/favicons/apple-touch-icon.png" /> <link rel="icon" type="image/png" sizes="32x32" href="../../App_plugins/IBE/assets/imgs/favicons/favicon-32x32.png" /> <link rel="icon" type="image/png" sizes="16x16" href="../../App_plugins/IBE/assets/imgs/favicons/favicon-16x16.png" /> <link rel="mask-icon" href="../../App_plugins/IBE/assets/imgs/favicons/safari-pinned-tab.svg" color="#6f2c91" /> <meta name="msapplication-TileColor" content="#6f2c91" /> <meta name="theme-color" content="#ffffff" /> <link href="../../App_Plugins/IBE/assets/styles/css-fonts/hke-fonts.css" rel="stylesheet" /> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> <title>HK Express - Select Flights</title> <link href="/App_Plugins/IBE/assets/styles/styles.min.css?v=My4x0d2i4IUr2jj/+TqsTQ==" rel="stylesheet" /> <!-- CDF: No CSS dependencies were declared //--> <link href="../App_Plugins/IBE/assets/styles/css-fonts/hke-fonts.css" rel="stylesheet" /> <script src="//assets.adobedtm.com/a818c3b96cf5ac3d93bff8e5ef5a01871372ed93/satelliteLib-f14334f19adf9941b6b218fc18a82ef8be18a788.js"></script><script src="https://assets.adobedtm.com/a818c3b96cf5ac3d93bff8e5ef5a01871372ed93/scripts/satellite-5c90a73464746d320b000997.js"></script><script src="https://dev.visualwebsiteoptimizer.com/j.php?a=382740&u=https%3A%2F%2Fbooking.hkexpress.com%2Fen-US%2Fselect%2F%3FSearchType%3DRETURN%26OriginStation%3DHKG%26DestinationStation%3DKIX%26DepartureDate%3D19%2F04%2F2019%26ReturnDate%3D26%2F04%2F2019%26Adults%3D1%26LowFareFinderSelected%3Dfalse&r=0.36533003984482404"></script><script src="https://assets.adobedtm.com/a818c3b96cf5ac3d93bff8e5ef5a01871372ed93/scripts/satellite-5c88c7a764746d78ad007663.js"></script><script src="https://www.googletagmanager.com/gtag/js?id=UA-41860655-7"></script> <script> _satellite.pageBottomFired = true; </script> <script> var page_data = {}; var isOmnitureEnabled = true; var isGranifyEnabled = false; </script>