Пример #1
0
def request_url(site, uri):
    res = requests.get(site)
    soup = BeautifulSoup(res.text, 'html.parser')
    uri = uri
    url = soup.select_one(uri)
    result = url.get('src')

    iframe = urls.urljoin(urls.getHostname(site, True), result)

    print (iframe)
    return iframe
Пример #2
0
from bs4 import BeautifulSoup
import requests
import urls

bbsUrl = "https://blog.naver.com/korea_diary/221433346994"
# bbsUrl = "https://blog.naver.com/d_ahae/221436343740"
# bbsUrl = "https://blog.naver.com/kkomataku/221437665643"
# bbsUrl = "https://blog.naver.com/baekmg1988/221405485574"
html = requests.get(bbsUrl).text
soup = BeautifulSoup(html, 'html.parser')

ifrSel = "iframe#mainFrame"
ifr = soup.select_one(ifrSel)
src = ifr.get('src')
orgUrl = urls.urljoin(urls.getHostname(bbsUrl, True), src)

orgHtml = requests.get(orgUrl).text
orgSoup = BeautifulSoup(orgHtml, 'html.parser')

titleSel = "div.se-title-text span"
titleEle = orgSoup.select_one(titleSel)
if not titleEle:
    titleEle = orgSoup.select_one('div.se_title')

if titleEle:
    title = titleEle.text.strip()
else:
    title = 'Title 못찾음!! ' + bbsUrl

# print("-->", title)
# exit()
Пример #3
0
from bs4 import BeautifulSoup
import requests
import urls

url_marketindex = "https://finance.naver.com/marketindex/"
html = requests.get(url_marketindex).text
soup = BeautifulSoup(html, 'html.parser')



ifrSel = "iframe#frame_ex1"
ifr = soup.select_one(ifrSel)
src = ifr.get('src')

orgUrl = urls.urljoin( urls.getHostname(url_marketindex, True), src )
# print(orgUrl)

orgHtml = requests.get(orgUrl).text
orgSoup = BeautifulSoup(orgHtml, 'html.parser')
# print(orgHtml)

# divSel = "div.tbl_area tbody td.tit a"
# divEles = orgSoup.select(divSel)
# print(divEles)

# table = orgSoup.html.tbody
# print(table)

# tr = table.tr

# print(trt)
Пример #4
0
from bs4 import BeautifulSoup
import requests
import urls

url = "https://finance.naver.com/marketindex/"
html = requests.get(url).text
soup = BeautifulSoup( html, 'html.parser')

iframe = 'iframe#frame_ex1'
ifsoup = soup.select_one(iframe)
ifsrc = ifsoup.get('src')

joinUrl = urls.urljoin( urls.getHostname(url, True), ifsrc)
joinHtml = requests.get(joinUrl).text
joinSoup = BeautifulSoup(joinHtml, 'html.parser')


source_len_tr = joinSoup.select('body > div > table > tbody > tr')
real_len = len(source_len_tr)

tr_sel = 'body > div > table > tbody > tr'
trs = joinSoup.select(tr_sel)

finance = []

print(" 국가  /  살 때  /  팔 때   /  환율차이 ")

for tr in trs :

    nation = tr.select('td')[0].text.split()[0]
    buy = tr.select('td')[1].text