Member Avatar for sravan953

Hey guys....

I want to make a program which reads the HTML code from my blog, saves the HTML code as a string, so that I can check if specific words are present in the HTML code, here's the code I used:

import urllib
import string

open_site=urllib.urlopen('http://www.sravan953.blogspot.com')
read_site=open_site.read()

value=str(read_site)

for item in value:
    print item

But it just doesn't work, because it takes each letter(or you could say character) one by one and runs it in the loop! How do I make it take one whole work at a time?

Thanks in advance
Sravan

Not sure what you mean...

import urllib
import string

open_site=urllib.urlopen('http://www.sravan953.blogspot.com')
read_site=open_site.read()

value=str(read_site)

print value
Member Avatar for sravan953

Not sure what you mean...

import urllib
import string

open_site=urllib.urlopen('http://www.sravan953.blogspot.com')
read_site=open_site.read()

value=str(read_site)

print value

Oh thanks...
BTW, I wanted to make a program which open a HTML file, and check if a specific word is there, upon which it shuts down the computer, here's the code I used:

import urllib
import os
import time

open_file=open('html.html','r')
file=open_file.read()

def shutdown():
    os.system('shutdown-s')

value=[]
for item in file:
    value.append(item)
    test=''.join(value)
    if test=='shutdown_now':
        shutdown()

But the shutdown script ain't working, can you help me? thanks!

Try:

import urllib
import os
import time

open_file=open('html.html','r')
file=open_file.read()

def shutdown():
    os.system('shutdown -s')

value=[]
for item in file:
    value.append(item)
    test=''.join(value)
    if test=='shutdown_now':
        shutdown()
commented: Great +1
Member Avatar for sravan953

Try:

import urllib
import os
import time

open_file=open('html.html','r')
file=open_file.read()

def shutdown():
    os.system('shutdown -s')

value=[]
for item in file:
    value.append(item)
    test=''.join(value)
    if test=='shutdown_now':
        shutdown()

Thanks mate, it worked! I just had give a space b/w 'shutdown' and '-s'...thanks a million!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.