Python + Selenium + Chromedriver: Monitoring network traffic












-1














I'm trying to capture all network traffic that we can see in Network tab of chromedevtools. After capturing network traffic, i'm filtering it to get only .m3u8 urls. I'm using seleniumwire with chromedriver for this purpose. I was able to capture .m3u8 link using the below script from this url:



https://www.canlitv.video/atv


But it is not working for these urls:



http://www.lalegultv.com.tr/canli-yayin
https://www.kanald.com.tr/canli-yayin


Here is the script that i'm using.



from seleniumwire import webdriver 
from selenium.webdriver.chrome.options import Options
from fake_useragent import UserAgent
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

ua = UserAgent()

d = DesiredCapabilities.CHROME

chrome_options = Options()
#chrome_options.headless = True
chrome_options.add_argument("--user-agent='"+ua.chrome+"'")
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--lang=en-GB,en-US;q=0.9,en;q=0.8')
# chrome_options.add_argument("--headless")
chrome_options.add_argument('--log-level=3')
chrome_options.add_argument("--start-maximized")
driver = webdriver.Chrome(chrome_options=chrome_options,service_args=["--verbose", "--log-path=C:/errors/chromedriver.log"],desired_capabilities=d)

# url = "https://www.kanald.com.tr/canli-yayin"
url = "http://www.lalegultv.com.tr/canli-yayin"

driver.get(url)

# logs all traffic inclusing .js, .png, .ico loads in a file named log.csv
f = open("traffic.csv","w")

for request in driver.requests:
try:
line = str(request.path) + "," + str(request.response.status_code) + "," + str(request.response.headers['Content-Type']) + "n"
f.write(line)
except:
pass
if request.response:
if ".m3u8" in request.path:
if request.path[-4:] == ".m3u8":
print(request.path)
if ".m3u8?" in request.path:
print(request.path)
f.close()

print("Testing logs --- ")
for entry in driver.get_log('browser'):
print(entry)

# driver.quit()


I tried in headless mode but the script is not fetching .m3u8 url. So i tried in headed mode, and i noticed a problem. When the page is loaded in normal browser the video is loading. But when launched using chromedriver it is not loading the video. Can anyone please help me fix this problem. You may please connect with me to discuss here. My aim is to get .m3u8 url from the urls that i give. I'm open to alternate solution.



Chrome Browser - Your connection to this site is not secure



Here are some additional details:



ChromeDriver 2.44.609538



Python 3.5.0



Selenium 3.141.0



Selenium-wire 0.10.0



Google Chrome 70.0.3538.102 (Official Build) (64-bit)










share|improve this question





























    -1














    I'm trying to capture all network traffic that we can see in Network tab of chromedevtools. After capturing network traffic, i'm filtering it to get only .m3u8 urls. I'm using seleniumwire with chromedriver for this purpose. I was able to capture .m3u8 link using the below script from this url:



    https://www.canlitv.video/atv


    But it is not working for these urls:



    http://www.lalegultv.com.tr/canli-yayin
    https://www.kanald.com.tr/canli-yayin


    Here is the script that i'm using.



    from seleniumwire import webdriver 
    from selenium.webdriver.chrome.options import Options
    from fake_useragent import UserAgent
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

    ua = UserAgent()

    d = DesiredCapabilities.CHROME

    chrome_options = Options()
    #chrome_options.headless = True
    chrome_options.add_argument("--user-agent='"+ua.chrome+"'")
    chrome_options.add_argument('--ignore-certificate-errors')
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--disable-gpu')
    chrome_options.add_argument('--disable-dev-shm-usage')
    chrome_options.add_argument('--lang=en-GB,en-US;q=0.9,en;q=0.8')
    # chrome_options.add_argument("--headless")
    chrome_options.add_argument('--log-level=3')
    chrome_options.add_argument("--start-maximized")
    driver = webdriver.Chrome(chrome_options=chrome_options,service_args=["--verbose", "--log-path=C:/errors/chromedriver.log"],desired_capabilities=d)

    # url = "https://www.kanald.com.tr/canli-yayin"
    url = "http://www.lalegultv.com.tr/canli-yayin"

    driver.get(url)

    # logs all traffic inclusing .js, .png, .ico loads in a file named log.csv
    f = open("traffic.csv","w")

    for request in driver.requests:
    try:
    line = str(request.path) + "," + str(request.response.status_code) + "," + str(request.response.headers['Content-Type']) + "n"
    f.write(line)
    except:
    pass
    if request.response:
    if ".m3u8" in request.path:
    if request.path[-4:] == ".m3u8":
    print(request.path)
    if ".m3u8?" in request.path:
    print(request.path)
    f.close()

    print("Testing logs --- ")
    for entry in driver.get_log('browser'):
    print(entry)

    # driver.quit()


    I tried in headless mode but the script is not fetching .m3u8 url. So i tried in headed mode, and i noticed a problem. When the page is loaded in normal browser the video is loading. But when launched using chromedriver it is not loading the video. Can anyone please help me fix this problem. You may please connect with me to discuss here. My aim is to get .m3u8 url from the urls that i give. I'm open to alternate solution.



    Chrome Browser - Your connection to this site is not secure



    Here are some additional details:



    ChromeDriver 2.44.609538



    Python 3.5.0



    Selenium 3.141.0



    Selenium-wire 0.10.0



    Google Chrome 70.0.3538.102 (Official Build) (64-bit)










    share|improve this question



























      -1












      -1








      -1







      I'm trying to capture all network traffic that we can see in Network tab of chromedevtools. After capturing network traffic, i'm filtering it to get only .m3u8 urls. I'm using seleniumwire with chromedriver for this purpose. I was able to capture .m3u8 link using the below script from this url:



      https://www.canlitv.video/atv


      But it is not working for these urls:



      http://www.lalegultv.com.tr/canli-yayin
      https://www.kanald.com.tr/canli-yayin


      Here is the script that i'm using.



      from seleniumwire import webdriver 
      from selenium.webdriver.chrome.options import Options
      from fake_useragent import UserAgent
      from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

      ua = UserAgent()

      d = DesiredCapabilities.CHROME

      chrome_options = Options()
      #chrome_options.headless = True
      chrome_options.add_argument("--user-agent='"+ua.chrome+"'")
      chrome_options.add_argument('--ignore-certificate-errors')
      chrome_options.add_argument('--no-sandbox')
      chrome_options.add_argument('--disable-gpu')
      chrome_options.add_argument('--disable-dev-shm-usage')
      chrome_options.add_argument('--lang=en-GB,en-US;q=0.9,en;q=0.8')
      # chrome_options.add_argument("--headless")
      chrome_options.add_argument('--log-level=3')
      chrome_options.add_argument("--start-maximized")
      driver = webdriver.Chrome(chrome_options=chrome_options,service_args=["--verbose", "--log-path=C:/errors/chromedriver.log"],desired_capabilities=d)

      # url = "https://www.kanald.com.tr/canli-yayin"
      url = "http://www.lalegultv.com.tr/canli-yayin"

      driver.get(url)

      # logs all traffic inclusing .js, .png, .ico loads in a file named log.csv
      f = open("traffic.csv","w")

      for request in driver.requests:
      try:
      line = str(request.path) + "," + str(request.response.status_code) + "," + str(request.response.headers['Content-Type']) + "n"
      f.write(line)
      except:
      pass
      if request.response:
      if ".m3u8" in request.path:
      if request.path[-4:] == ".m3u8":
      print(request.path)
      if ".m3u8?" in request.path:
      print(request.path)
      f.close()

      print("Testing logs --- ")
      for entry in driver.get_log('browser'):
      print(entry)

      # driver.quit()


      I tried in headless mode but the script is not fetching .m3u8 url. So i tried in headed mode, and i noticed a problem. When the page is loaded in normal browser the video is loading. But when launched using chromedriver it is not loading the video. Can anyone please help me fix this problem. You may please connect with me to discuss here. My aim is to get .m3u8 url from the urls that i give. I'm open to alternate solution.



      Chrome Browser - Your connection to this site is not secure



      Here are some additional details:



      ChromeDriver 2.44.609538



      Python 3.5.0



      Selenium 3.141.0



      Selenium-wire 0.10.0



      Google Chrome 70.0.3538.102 (Official Build) (64-bit)










      share|improve this question















      I'm trying to capture all network traffic that we can see in Network tab of chromedevtools. After capturing network traffic, i'm filtering it to get only .m3u8 urls. I'm using seleniumwire with chromedriver for this purpose. I was able to capture .m3u8 link using the below script from this url:



      https://www.canlitv.video/atv


      But it is not working for these urls:



      http://www.lalegultv.com.tr/canli-yayin
      https://www.kanald.com.tr/canli-yayin


      Here is the script that i'm using.



      from seleniumwire import webdriver 
      from selenium.webdriver.chrome.options import Options
      from fake_useragent import UserAgent
      from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

      ua = UserAgent()

      d = DesiredCapabilities.CHROME

      chrome_options = Options()
      #chrome_options.headless = True
      chrome_options.add_argument("--user-agent='"+ua.chrome+"'")
      chrome_options.add_argument('--ignore-certificate-errors')
      chrome_options.add_argument('--no-sandbox')
      chrome_options.add_argument('--disable-gpu')
      chrome_options.add_argument('--disable-dev-shm-usage')
      chrome_options.add_argument('--lang=en-GB,en-US;q=0.9,en;q=0.8')
      # chrome_options.add_argument("--headless")
      chrome_options.add_argument('--log-level=3')
      chrome_options.add_argument("--start-maximized")
      driver = webdriver.Chrome(chrome_options=chrome_options,service_args=["--verbose", "--log-path=C:/errors/chromedriver.log"],desired_capabilities=d)

      # url = "https://www.kanald.com.tr/canli-yayin"
      url = "http://www.lalegultv.com.tr/canli-yayin"

      driver.get(url)

      # logs all traffic inclusing .js, .png, .ico loads in a file named log.csv
      f = open("traffic.csv","w")

      for request in driver.requests:
      try:
      line = str(request.path) + "," + str(request.response.status_code) + "," + str(request.response.headers['Content-Type']) + "n"
      f.write(line)
      except:
      pass
      if request.response:
      if ".m3u8" in request.path:
      if request.path[-4:] == ".m3u8":
      print(request.path)
      if ".m3u8?" in request.path:
      print(request.path)
      f.close()

      print("Testing logs --- ")
      for entry in driver.get_log('browser'):
      print(entry)

      # driver.quit()


      I tried in headless mode but the script is not fetching .m3u8 url. So i tried in headed mode, and i noticed a problem. When the page is loaded in normal browser the video is loading. But when launched using chromedriver it is not loading the video. Can anyone please help me fix this problem. You may please connect with me to discuss here. My aim is to get .m3u8 url from the urls that i give. I'm open to alternate solution.



      Chrome Browser - Your connection to this site is not secure



      Here are some additional details:



      ChromeDriver 2.44.609538



      Python 3.5.0



      Selenium 3.141.0



      Selenium-wire 0.10.0



      Google Chrome 70.0.3538.102 (Official Build) (64-bit)







      python selenium google-chrome selenium-chromedriver seleniumwire






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 at 6:14

























      asked Nov 23 at 4:49









      Mr Employee

      12




      12





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440795%2fpython-selenium-chromedriver-monitoring-network-traffic%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440795%2fpython-selenium-chromedriver-monitoring-network-traffic%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks