Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 我可能会有一些韩文信件。_Python 3.x_Encoding_Web Crawler - Fatal编程技术网

Python 3.x 我可能会有一些韩文信件。

Python 3.x 我可能会有一些韩文信件。,python-3.x,encoding,web-crawler,Python 3.x,Encoding,Web Crawler,我正在使用python 3.6和pycharm 2016.2,并尝试对网站进行爬网 在"的范畴内,보험사고이력 정보 : 내차 피해" (包括第五个表),如果其中一个“p tag”有“-사고일자“在内容上 下面是我的代码。它一直不返回任何内容 请帮忙 from bs4 import BeautifulSoup import urllib.request from urllib.parse import urlparse import re popup_insurance = "http://w

我正在使用python 3.6和pycharm 2016.2,并尝试对网站进行爬网

在"的范畴内,보험사고이력 정보 : 내차 피해" (包括第五个表),如果其中一个“p tag”有“-사고일자“在内容上

下面是我的代码。它一直不返回任何内容

请帮忙

from bs4 import BeautifulSoup
import urllib.request
from urllib.parse import urlparse
import re

popup_insurance = "http://www.bobaedream.co.kr/mycar/popup/mycarChart_B.php?car_number=35%EB%91%908475&tbl=cyber&cno=651451"
res = urllib.request.urlopen(popup_insurance)
html = res.read()
soup_insurance = BeautifulSoup(html, 'html.parser')
insurance_content_table = soup_insurance.find_all('table')

elem = soup_insurance.find("p", text="보험사고이력 정보 : 내차 피해")
while elem.string != "보험사고이력 정보 : 타차 가해":
    if "사고일자" in elem.next_sibling:
        print(elem.next_sibling)

    elem = elem.next_sibling

    if elem is None:
        break

你应该在
元素中循环。下一个兄弟姐妹
导航字符串有时可能很奇怪:

from bs4 import BeautifulSoup
import urllib.request
from urllib.parse import urlparse
import re

popup_insurance = "http://www.bobaedream.co.kr/mycar/popup/mycarChart_B.php?car_number=35%EB%91%908475&tbl=cyber&cno=651451"
res = urllib.request.urlopen(popup_insurance)
html = res.read()
soup_insurance = BeautifulSoup(html, 'html.parser')
insurance_content_table = soup_insurance.find_all('table')

elem = soup_insurance.find("p", text="보험사고이력 정보 : 내차 피해")
while elem.string != "보험사고이력 정보 : 타차 가해":
    for string in elem.next_sibling:
        if "사고일자" in string:
            print(elem.next_sibling.string.strip())

    elem = elem.next_sibling

    if elem is None:
        break
我假设(因为您没有提供预期输出),您想要事故日期/维修成本位

这还远远不够完美,甚至不够优雅,我几乎可以肯定的是,只要使用for循环就可以做到这一点