Answer the question
In order to leave comments, you need to log in
How to parse the registration date of VK in Python?
Hello everyone, how to parse the date of registration in python from: https://vk.com/foaf.php?id=554205532
When outputting this code
<?xml version="1.0" encoding="WINDOWS-1251"?>
<rdf:RDF
xml:lang="ru"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:ya="http://blogs.yandex.ru/schema/foaf/"
xmlns:img="http://blogs.yandex.ru/schema/foaf/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<foaf:Person>
<ya:publicAccess>allowed</ya:publicAccess>
<ya:profileState>active</ya:profileState>
<ya:URI ya:primary="yes" rdf:resource="http://vk.com/id554205532"/>
<ya:URI rdf:resource="http://vk.com/peter.parkers"/>
<ya:firstName>Peter</ya:firstName>
<ya:secondName>Parker</ya:secondName>
<foaf:name>Peter Parker</foaf:name>
<foaf:weblog
dc:title=""
rdf:resource="http://vk.com/peter.parkers"/>
<foaf:gender>male</foaf:gender>
<ya:created dc:date="2019-07-21T22:17:38+03:00"/>
<ya:lastLoggedIn dc:date="2019-07-25T20:15:19+03:00"/>
<ya:modified dc:date="2019-07-21T22:26:00+03:00"/>
<ya:subscribersCount>0</ya:subscribersCount>
<ya:friendsCount>18</ya:friendsCount>
<ya:subscribedToCount>0</ya:subscribedToCount>
<foaf:birthday>08-10</foaf:birthday>
<foaf:dateOfBirth>2001-08-10</foaf:dateOfBirth>
<foaf:img>
<foaf:Image ya:primary="yes" img:width="200" img:height="200"
rdf:about="https://sun7-9.userapi.com/c855224/v855224038/9f700/s_S9w2H4kpo.jpg?ava=1">
<foaf:thumbnail img:width="100" img:height="100" rdf:resource="https://sun7-9.userapi.com/c855224/v855224038/9f701/4nHJR2bAkgI.jpg?ava=1"/>
<foaf:thumbnail img:width="50" img:height="50" rdf:resource="https://sun7-6.userapi.com/c855224/v855224038/9f702/8Wv_gSkGHP8.jpg?ava=1"/>
</foaf:Image>
</foaf:img>
<foaf:familyStatus>inlove</foaf:familyStatus>
<ya:job>
<ya:workPlace
dc:title=""
rdf:about="http://yandex.ru/yandsearch?text=%2C%20">
</ya:workPlace>
</ya:job>
</foaf:Person>
</rdf:RDF>
Answer the question
In order to leave comments, you need to log in
take a ready-made tool for working with RDF ( rdflib ) or use the xmltodict library
from bs4 import BeautifulSoup
import requests
response = requests.get('https://vk.com/foaf.php?id=554205532')
xml = response.text
soup = BeautifulSoup(xml, 'lxml')
created = soup.find('ya:created').get('dc:date')
print(created)
>>> 2019-07-21T22:17:38+03:00
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question