go on website to get stats and geographical position
This commit is contained in:
parent
7140033b3d
commit
de14f239ed
2 changed files with 31 additions and 3 deletions
|
|
@ -26,7 +26,7 @@ import re
|
||||||
import urllib
|
import urllib
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword, BrowserHTTPNotFound
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword, BrowserHTTPNotFound, BrowserUnavailable
|
||||||
from weboob.tools.json import json
|
from weboob.tools.json import json
|
||||||
from weboob.tools.date import local2utc
|
from weboob.tools.date import local2utc
|
||||||
|
|
||||||
|
|
@ -189,6 +189,9 @@ class AuMBrowser(BaseBrowser):
|
||||||
self.my_id = int(r['user']['id'])
|
self.my_id = int(r['user']['id'])
|
||||||
self.my_name = r['user']['pseudo']
|
self.my_name = r['user']['pseudo']
|
||||||
|
|
||||||
|
profile = self.get_profile(self.my_id)
|
||||||
|
self.my_coords = [profile['lat'], profile['lng']]
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def get_consts(self):
|
def get_consts(self):
|
||||||
|
|
@ -305,6 +308,31 @@ class AuMBrowser(BaseBrowser):
|
||||||
|
|
||||||
profile.update(self.api_request('users/%s' % id))
|
profile.update(self.api_request('users/%s' % id))
|
||||||
|
|
||||||
|
try:
|
||||||
|
doc = self.get_document(self.openurl('http://www.adopteunmec.com/profile/%s' % id))
|
||||||
|
except BrowserUnavailable:
|
||||||
|
self.logger.warning('Unable to find profile of %s on website' % id)
|
||||||
|
else:
|
||||||
|
profile['popu'] = {}
|
||||||
|
for tr in doc.xpath('//div[@id="popularity"]//tr'):
|
||||||
|
cols = tr.findall('td')
|
||||||
|
if cols[0].text is None:
|
||||||
|
continue
|
||||||
|
key = self.parser.tocleanstring(tr.find('th')).strip().lower()
|
||||||
|
value = int(re.sub(u'[ \xa0x]+', u'', cols[0].text).strip())
|
||||||
|
profile['popu'][key] = value
|
||||||
|
|
||||||
|
for script in doc.xpath('//script'):
|
||||||
|
text = script.text
|
||||||
|
if text is None:
|
||||||
|
continue
|
||||||
|
m = re.search('memberLat: ([\d\.]+),', text, re.IGNORECASE)
|
||||||
|
if m:
|
||||||
|
profile['lat'] = float(m.group(1))
|
||||||
|
m = re.search('memberLng: ([\d\.]+),', text, re.IGNORECASE)
|
||||||
|
if m:
|
||||||
|
profile['lng'] = float(m.group(1))
|
||||||
|
|
||||||
# Calculate distance in km.
|
# Calculate distance in km.
|
||||||
profile['dist'] = 0.0
|
profile['dist'] = 0.0
|
||||||
if 'lat' in profile and 'lng' in profile:
|
if 'lat' in profile and 'lng' in profile:
|
||||||
|
|
|
||||||
|
|
@ -153,9 +153,9 @@ class Contact(_Contact):
|
||||||
))),
|
))),
|
||||||
('_stats', OrderedDict((
|
('_stats', OrderedDict((
|
||||||
('mails', FieldPopu('mails')),
|
('mails', FieldPopu('mails')),
|
||||||
('baskets', FieldPopu('contacts')),
|
('charms', FieldPopu('charmes')),
|
||||||
('charms', FieldPopu('flashs')),
|
|
||||||
('visites', FieldPopu('visites')),
|
('visites', FieldPopu('visites')),
|
||||||
|
('baskets', FieldPopu('panier')),
|
||||||
('invits', FieldPopu('invits')),
|
('invits', FieldPopu('invits')),
|
||||||
('bonus', FieldPopu('bonus')),
|
('bonus', FieldPopu('bonus')),
|
||||||
('score', FieldStr('points')),
|
('score', FieldStr('points')),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue