Первая прога на питоне, не пинайте сильно.
Вот этот код не работает :(
import urllib.request
import re
class Travian:
def __init__():
pass
def loginPage(self):
data = urllib.request.urlopen("http://" + self.server)
data = data.read()
return data
def loginForm(self):
lp = self.loginPage()
re.search("<form.*?<\/form>", lp, re.M)
def login(self, user, password):
lf = self.loginForm()
pass
class Main(Travian):
def __init__(self):
self.server = "speed.travian.ru"
def start(self):
self.login("", "")
m = Main()
m.start()
Traceback (most recent call last):
File "./main.py", line 32, in <module>
m.start()
File "./main.py", line 28, in start
self.login("", "")
File "./main.py", line 20, in login
lf = self.loginForm()
File "./main.py", line 17, in loginForm
re.search("<form.*?<\/form>", lp, re.M)
File "/opt/python3//lib/python3.0/re.py", line 157, in search
return _compile(pattern, flags).search(string)
TypeError: can't use a string pattern on a bytes-like object
Как лечить ?
Заранее благодярю…
Олег.