Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Extract text from meta content

let us suppose we are given following site : prices of homes in tbilisi

There is fragment of my code that i have implemented and its corresponding result :

div_class =content.find_all("div",class_='sc-8fa2c16a-5 gpNUxi')
for  div in div_class:
    prices.append(div.text)
    subcontent =requests.get(base_link+div.a['href'])
    subcontent =BeautifulSoup(subcontent.text,'html.parser')
    meta=subcontent.find_all("meta",property='og:description')
    print(meta[0])

and returned result is :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<meta content="იყიდება 4 ოთახიანი ბინა. თეთრი კარკასი. ორი სველი წერტილი. (ერთი სველი წერტილი გარემონტებულია) დიდი ტერასითა და მოწესრიგებული სადარბაზოთი. დახურული ეზო შლაგბაუმით. ვარ მესაკუთრე. მეტროდან 
მაქსიმუმ 5 წუთის სავალზე.
სველი წერტილები ისეა განლაგებული შესაძლებელია მარტივატ ორ ბინად დაყოფა. 

ფასზე დალაპარაკება შესაძლებელია.
01.11.12.018.202

" property="og:description"/>

how can i extract text from it? i have tried meta[0].text, but it does not show result yet, please any suggestion?

>Solution :

The element you looking for dont have the data you want as text, is in the attribute "content", so to access it you can use .attrs["x"]

meta[0].attrs["content"]

extra:

if there are no more element meta with that property, your can change "find_all(..)" to "find(..)" and "meta[0]" to just "meta" because it wont return a list, just the element

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading