0
import requests
s = ['jobs','careers','opportunities']
u = ['yahoo.com','statestreet.com']
f = []

for i in u:
    for j in s:
        w = "http://{}/{}".format(i,j)
        print w
        r = requests.get(w)
        print r.status_code
            if(r.status_code == 200):
                f.append(w)
                break
        print f

This code is working for most websites but not for websites like www.surveymonkey.com.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
jyothi
  • 11
  • 1
  • How is it not working (for www.surveymonkey.com)? Is there an error message, or does it not behave as expected? – Jonny Feb 20 '17 at 20:18

1 Answers1

0

You don't state what isn't working, or what you expect the code to do. However, the indentation in the final if statement in your code seems incorrect.

Correcting that (and editing the variable names to be more descriptive as follows) at least runs as expected for me:

import requests

paths = ['jobs', 'careers', 'opportunities']
domains = ['yahoo.com', 'statestreet.com', 'surveymonkey.com']
results = []

for domain in domains:
    for path in paths:
        url = "http://{}/{}".format(domain, path)
        print url
        r = requests.get(url)
        print r.status_code
        if r.status_code == requests.codes.OK:
            results.append(url)
            break
print results
Jonny
  • 3,807
  • 8
  • 31
  • 48
  • Thanks for correcting. Most of the domains are working with this code but not survey monkey. – jyothi Feb 21 '17 at 20:59
  • SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590) – jyothi Feb 21 '17 at 21:02
  • Surveymonkey works fine for me in the above code. Can you access http://surveymonkey.com/jobs directly from the machine you are developping on? What site gave the error you posted? – Jonny Feb 21 '17 at 21:46
  • [This post](http://stackoverflow.com/questions/35405092/sslerror-sslv3-alert-handshake-failure) may help with the SSLV3 Handshake failure. – Jonny Feb 21 '17 at 21:50