Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
from urllib.request import urlopen
from urllib import parse
import re
print ("Enter the URL you wish to crawl..")
myurl = input("the url")
def getdata(myurl):
for i in re.findall('''href=["'](.[^"']+)["']''', urllib.urlopen(sys.argv[1]).read(), re.I):
print i
for ee in re.findall('''href=["'](.[^"']+)["']''', urllib.urlopen(i).read(), re.I):
print ee


error i am getting

C:\Users\user-pc\Documents\Python>python urlcrawler.py
File "urlcrawler.py", line 7
for i in re.findall('''href=["'](.[^"']+)["']''', urllib.urlopen(sys.argv[1]
).read(), re.I):
IndentationError: expected an indented block

What I have tried:

tried searching the error but not getting approx results
Posted
Updated 8-Jul-18 7:32am
Comments
Patrice T 8-Jul-18 14:03pm    
Show your code with actual indentation.

Your code is not indented correctly, as reported in the error message. Forget searching and read the Python documentation: 3. An Informal Introduction to Python — Python 3.7.0 documentation[^]
 
Share this answer
 
The error explains the problem pretty well. The body of a for loop must be indented.

for i in re.findall('''href=["'](.[^"']+)["']''', urllib.urlopen(sys.argv[1]).read(), re.I):
    print i
    for ee in re.findall('''href=["'](.[^"']+)["']''', urllib.urlopen(i).read(), re.I):
        print ee
 
Share this answer
 
v2
Comments
Member 13888852 9-Jul-18 0:30am    
What do you mean by indented how can I get my code working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900