0

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

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by sravan953
Featured Replies
  • 1
    scru 909   7 Years Ago

    Try: [code=python] 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() [/code] Read More

0

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!

1

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()
Comments
Great
0

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!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.