2

I have to visit a list of URLs but I do not want to open those which will start a download.

for url in url_list:
   if (url will not start a download):
      driver.get(url)
      ..................
   else:
      continue

Does someone have a solution for this? thanks in advance for the answers

3
  • 1
    What conditions have you tried? Have you seen any difference between a regular URL an a URL that will start a download? Maybe the one that triggers a download will contain the extension of the file and you can check if some extensions like .pdf, .mp4 are in the URL or maybe you can check with a regular expression. Try some things, add the code here + URL samples. Commented Sep 15, 2016 at 8:35
  • Checking the URLs is indeed a very nice option, I have implemented it and reduced the problem a little bit, however I still have problems when a redirection is involved, do you have any alternative for that? Commented Sep 16, 2016 at 9:02
  • Please update your question with details of what happens, and see if is anything specific in the case, maybe the url contains a specific string. Commented Sep 16, 2016 at 9:09

1 Answer 1

2

first you can get url then in java with selenium you can below condition in if:

(String)((JavascriptExecutor) driver).executeScript("return document.contentType;").equals("text/html");
Sign up to request clarification or add additional context in comments.

2 Comments

The question is about how to do it in Python.
it must have similar solution in python. I found that and edit it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.