Can any one please tell me how to display the result in notepad

For Example My code :

import urllib
a = urllib.urlopen("https://www.google.com")
Source = a.read()
print Source

raw_input("*************Press Enter to Exit****************");

i have to display the result of it in a note pad.

6 Years
Discussion Span
Last Post by richieking

Use the SendKeys module. Google it and download it. The module sends keystrokes and values to the open window.
Read through the example files and things should be pretty clear...


Or you could just save the data you got from website to a file and open it with os.system(). SendKeys is only available on windows(I believe) and you run into the problem of making sure the active window is notepad.


You will need the API for notepad python bindings.

Its not like the webbrowser.

Or write your own notepad in 1 hour or less. Or a basic GUI to display your data for 10-20 munites.

wxPython baby.... ;)

Edited by richieking: n/a


It tok my 5sek to display result in notepad ctrl-c and ctrl-v.
So to the question why to you need to display source code in notepad?

Just to show you one normal to take out som info from a website.

from BeautifulSoup import BeautifulSoup
import urllib

url = urllib.urlopen('http://beans.itcarlow.ie/prices.html')
soup = BeautifulSoup(url)
print soup #site conteds,this is the source code no need to display it in notepad.

tag = soup.findAll('strong')
print tag[0].text  #$6.36 ##We have taken out price of bean from website

Edited by snippsat: n/a


With pywinauto sending the source code html to notepad,not that i understand why you need this.
Just copy and paste into notepad will be my easy answer for this.
With a bigger website i guess sending to much text to notepad will break,or you have to break up source code.

import urllib
from pywinauto import application

url = urllib.urlopen("http://beans.itcarlow.ie/prices.html")
Source = url.read()
app = application.Application()

Edited by snippsat: n/a

os.system('notepad.exe file')

works for me. Leaves the ugly command prompt window open and won't return control to python interpreter though...


python Syntax (Toggle Plain Text)

os.system('notepad.exe file')

os.system('notepad.exe file')
works for me. Leaves the ugly command prompt window open and won't return control to python interpreter though...

This will open the notepad with the file/info you provided. In your case file as the opened file name.

Its not the solution .....


The OP just wanted to display the info they retrieved from the webpage. Is it really that hard for them to figure out that you can save the info you returned from a webpage to a file? Oh and BTW

import os
os.popen('notepad.exe file')

starts the command window in a new process so it won't halt your program.


Let's go back to the original problem spec: what exactly does the assignment say? Does it have to actually open the program Notepad.exe, or do you simply need to display the results in some kind of textbox? Does the data have to be editable? Does it have to be saved to a file, and is it just a scratch file or do you need to let the user give it a specific name? Can you post the actual assignment for us?

Edited by Schol-R-LEA: n/a

os.popen("foo bar")

well do the job as long as he is willing to save his scrapped webpage and reopen it.

This topic has been dead for over six months. 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.