Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

python - With regards to urllib AttributeError: 'module' object has no attribute 'urlopen' -


import re import string import shutil import os import os.path import time import datetime import math import urllib array import array import random  filehandle = urllib.urlopen('http://www.google.com/') #open webpage s = filehandle.read() #read  print s #display  #what plan once first part working #results = re.findall('[<td style="font-weight:bold;" nowrap>$][0-9][0-9][0-9][.][0-9][0-9][</td></tr></tfoot></table>]',s) #earnings = '$ ' #for money in results: #earnings = earnings + money[1]+money[2]+money[3]+'.'+money[5]+money[6] #print earnings #raw_input() 

this code have far. have looked @ other forums give solutions such name of script, parse_money.py, , have tried doing urllib.request.urlopen , have tried running on python 2.5, 2.6, , 2.7. if has suggestions welcome, everyone!! --matt

---edit--- tried code , worked, im thinking kind of syntax error, if sharp eye can point out, appreciative.

import shutil import os import os.path import time import datetime import math import urllib array import array import random b = 3  #find url url = raw_input('type url read from[example: http://www.google.com/] :')    while b == 3:     #get file name     file1 = raw_input('enter file name downloaded code:')     filepath = file1 + '.txt'     if os.path.isfile(filepath):         print 'file exists'         b = 3     else:         print 'filename accepted'         b = 4  file_path = filepath #open file filewrite = open(file_path, 'a')   #acces url filehandle = urllib.urlopen(url)  #display souce code lines in filehandle.readlines():     filewrite.write(lines)     print lines print 'the above has been saved in both text , html file'  #close files filehandle.close() filewrite.close() 

it appears urlopen method available in urllib.request module , not in urllib module you're expecting.

rule of thumb - if you're getting attributeerror, field/operation not present in particular module.

edit - andidog pointing out - solution valid py 3.x, , not applicable py2.x!


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -