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 8127031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:22:32+00:00 2026-06-06T07:22:32+00:00

I don’t know what to do, I have a 39 line Python script and

  • 0

I don’t know what to do, I have a 39 line Python script and it gives me an error on line 40! 🙁 Error:

Traceback (most recent call last):
File "C:\Mass Storage\pythonscripts\Internet\execute.py", line 2, in <module>
execfile("firstrunSoup.py")
File "firstrunSoup.py", line 40

                                ^
SyntaxError: invalid syntax

C:\Mass Storage\pythonscripts\Internet>

And here’s my Python code:

###firstrunSoup.py###
FILE = open("startURL","r") #Grab from
stURL = FILE.read() #Read first line
FILE.close() #Close
file2save = "index.txt" #File to save URLs to

jscriptV = "not"
try:
    #Returns true/false for absolute
    def is_absolute(url):
        return bool(urlparse.urlparse(url).scheme)

    #Imports
    import urllib2,sys,time,re,urlparse
    from bs4 import BeautifulSoup

    cpURL = urllib2.urlopen(stURL) #Human-readable to computer-usable
    soup = BeautifulSoup(cpURL) #Defines soup

    FILE = open(file2save,"a")
    for link in soup.find_all('a'): #Find all anchor tags
        outPut = ""
        checkVar = link.get('href') #Puts href into string
        if (checkVar is not None) and (checkVar != ""): #Checks if defined
            if len(checkVar) > 11: #Check if longer than 11 characters
                if checkVar[:11] != "javascript:": #Check if first 11 are "javascript:"
                    if checkVar[:7] != "mailto:": #Check if first 7 are "mailto:"
                        jscriptV = "not"
                    else: jscriptV = ""
                else: jscriptV = ""
            if checkVar != "#" and checkVar != "/":
                if jscriptV == "not":
                    if checkVar is not None: #Checks if defined
                        if is_absolute(checkVar): outPut = checkVar.split("#")[0]
                        else: outPut = urlparse.urljoin(stURL,checkVar).split("#")[0]
                    if outPut != "":
                        print outPut
                        FILE.write(outPut + "\r\n")
                        FILE.close()
execfile("nextrunsSoup.py")

If you can help me, please do. I’ve spent many hours on this so far, and when it’s finally ready, I get this. Thanks in advance!

  • 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-06T07:22:34+00:00Added an answer on June 6, 2026 at 7:22 am

    you dont have a matching except for your try

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

Sidebar

Related Questions

Don't know what to do with this error. How to add data in SQL
Don't know if this has been answered before. Have custom routes to users. If
I don't have much PHP experience and I want to know how to best
Don't know why but I can't find a solution to this. I have 3
Don't know why this conversion fails. SELECT CAST('32.999' AS INT) throws the error saying
Don't know the term for the red validation border, does it have one? I
don't know better title for this, but here's my code. I have class user
Don't know what the term is called (substitution?), but in python if you type
Don't really know how to formulate the title, but it should be pretty obvious
Don't know how to google for such, but is there a way to query

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.