Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions GeneanetForGramps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ def random_headers():
page = s.get(purl)
if page.status_code == "302":
LOG.debug('Need to log in?')
self.connexion(self.user, self.password)
LOG.info('content %s' % str(page.content))
LOG.info('text %s' % page.text)
LOG.info('type %s' % page.headers['Content-Type'])
Expand Down Expand Up @@ -1287,7 +1288,11 @@ def random_headers():
if verbosity >= 2:
print(_("Birth place:"), self.g_birthplace)
except:
self.g_birthplace = str(uuid.uuid3(uuid.NAMESPACE_URL, self.url))
if len(birth) < 1:
pass
else:
LOG.debug(str(birth[0]))
self.g_birthplace = str(uuid.uuid3(uuid.NAMESPACE_URL, self.url))
try:
self.g_birthplacecode = str(' '.join(birth[0].split('-')[1:]).split(',')[1]).strip()
match = re.search(r'\d\d\d\d\d', self.g_birthplacecode)
Expand All @@ -1311,7 +1316,11 @@ def random_headers():
if verbosity >= 2:
print(_("Death place:"), self.g_deathplace)
except:
self.g_deathplace = str(uuid.uuid3(uuid.NAMESPACE_URL, self.url))
if len(death) < 1:
pass
else:
LOG.debug(str(death[0]))
self.g_deathplace = str(uuid.uuid3(uuid.NAMESPACE_URL, self.url))
try:
self.g_deathplacecode = str(' '.join(death[0].split('-')[1:]).split(',')[1]).strip()
match = re.search(r'\d\d\d\d\d', self.g_deathplacecode)
Expand Down Expand Up @@ -1462,6 +1471,39 @@ def random_headers():

else:
print(_("We failed to be ok with the server"))

def connexion(self, user, password):
'''
Login and password set for geneanet servers
'''
import requests

headers = {'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36' }
r = requests.get("https://www.geneanet.org/connexion/"
,headers=headers
)

pos1 = r.text.find('name="_csrf_token" value="')
pos1 = pos1 + len('name="_csrf_token" value="')
pos2 = r.text.find('"', pos1)
csrf = r.text[pos1:pos2]
cooks=r.cookies
headers.update({'referer':'https://www.geneanet.org/connexion/'})
headers.update({'authority':'www.geneanet.org'})
r = requests.post(
"https://www.geneanet.org/connexion/login_check"
,data={
"_username": user
,"_password": password
,"_submit": ""
,"_remember_me": "1"
,"_csrf_token": csrf
}
,allow_redirects=False
,cookies=cooks
,headers=headers
)
return(r.text)


def create_grampsp(self):
Expand Down