Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:48:36+00:00 2026-06-18T09:48:36+00:00

I have a python script which searches a web page for information. currently I

  • 0

I have a python script which searches a web page for information. currently I add the search term as a parameter when i run my program ‘myscript.py searchterm’.

What I would like to do is to have a file with my search terms in, get my script to loop through each one in turn on its own.

so I would populate my list from a file like this….

with open('mylist.txt', 'r') as f:
    searchterms = f.readlines()

I already have my code which looks something like this…just to give you an idea of layout…

counter = 0
try:
    while counter <10:

    #do some other stuff here

    counter=counter+10

except IOError:
    print "No result found!"+""

I need to wrap this in another loop to do this for every item in my list and I’m failing.

I know I need to reset the counter if it gets to 10, move onto my next list item and loop through the above but I don’t know how.
I find the python docs difficult to understand and I would appreciate a little help.

TIA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:48:38+00:00Added an answer on June 18, 2026 at 9:48 am

    If you have a list of search terms, you can easily loop through them and pass them to your existing loop like:

    for searchterm in searchterms:   
        counter = 0
        try:
            while counter <10:
    
            #do some other stuff here with searchterm
    
            counter=counter+10
    
        except IOError:
            print "No result found!"+""
    

    Be sure that your counter correctly resets at the beginning of each search term’s loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have python script which downloads N number of images from website. I run
I have a python script that runs a program, which generates few .exe files
I have a python script which I would like to run at regular intervals.
I have a python script which makes a GUI. When a button 'Run' is
I have a Python script which takes a long time to run. I'd quite
I have a python script which scrapes a page and receives a cookie. I
I have a python script which uses subprocess.Popen to run multiple instances of another
I have a C program which calls fork() And I have a python script
I have a python script which outputs lots of data, sample is as below.
i have a python script which keeps crashing on: subprocess.call([pdftotext, pdf_filename]) the error being:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.