I’m wondering how to write this in python and connect it to django app. I mean extracting values from meta tags and img url having only url of website. The same as facebook do when user is pasting the link.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Personally, I would choose to tackle this with the very nice Requests, BeautifulSoup, and LXML libraries.
Assuming we have the following model in
models.py, we could override thesave()method to populate thetitle,description, andkeywordsattributes:The logic from the overridden
save()method could very well live in a view or utility function or even in another method on theLinkmodel that could be called conditionally.The above works with Django 1.4. No guarantees, but it should work on earlier versions as well.
Edit: Fix syntax error and mention alternative parser, thanks @jinesh and @stonefury.