mercredi 6 juin 2018

How to Loop down 2 lists, until One item is found

What im looking to do is create a basic python script that reads from 2 text files, one with url's and the other one with key words and i want the script to check the first site if any of the keywords are on that site and when it finds that keyword print which site it was on. And then go to the next URl on the list and do the same thing. Not entirely sure how to go about this. I have somthing along these lines but am getting alot of errors.

import os 
import urllib.request

for link, key_word in open('url.txt', 'word.txt'):
  site = urllib.request.urlopen(link) 
  if key_word in site:
      print(key_word + 'was found on ' + link)
  else:
      print('Nothing was found')




Aucun commentaire:

Enregistrer un commentaire