“Ambil konten di dalam meta tag python” Kode Jawaban

Ambil konten di dalam meta tag python

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

Ambil konten di dalam meta tag python

#!/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

Ambil konten di dalam meta tag python

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

Jawaban yang mirip dengan “Ambil konten di dalam meta tag python”

Pertanyaan yang mirip dengan “Ambil konten di dalam meta tag python”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya