“odzyskać zawartość w meta tagu meta” Kod odpowiedzi

odzyskać zawartość w meta tagu meta

title = soup.find("meta",  property="og:title")
url = soup.find("meta",  property="og:url")

print(title["content"] if title else "No meta title given")
print(url["content"] if url else "No meta url given")
bharath

odzyskać zawartość w meta tagu meta

#!/usr/bin/env python
# -*- coding: utf-8 -*-

#importing the libraries
from urllib import urlopen
from bs4 import BeautifulSoup

def get_data(page_no):
    webpage = urlopen('http://superfunevents.com/?p=' + str(i)).read()
    soup = BeautifulSoup(webpage, "lxml")
    for tag in soup.find_all("article") :
        id = tag.get('id')
        print id
# the hard part that doesn't work - I know this example is well off the mark!        
    title = soup.find("og:title", "content")
    print (title.get_text())
    url = soup.find("og:url", "content")
    print (url.get_text())
# end of problem

for i in range (1,100):
    get_data(i)
bharath

odzyskać zawartość w meta tagu meta

soup = BeautifulSoup(webpage)
for tag in soup.find_all("meta"):
    if tag.get("property", None) == "og:title":
        print tag.get("content", None)
    elif tag.get("property", None) == "og:url":
        print tag.get("content", None)
bharath

Odpowiedzi podobne do “odzyskać zawartość w meta tagu meta”

Pytania podobne do “odzyskać zawartość w meta tagu meta”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu