无法从div部分提取数据

时间:2018-08-31 11:07:52

标签: python web-scraping

我想从下面的URL中提取主机名和IP,但是什么也没返回。

import requests
from bs4 import BeautifulSoup

url = "https://mxtoolbox.com/SuperTool.aspx?action=mx%3abuildersinmysore.com&run=toolpage"

response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')

divs = soup.find_all('div', {'class':'tool-result-body'})
#table = soup.find_all('table', {'class': 'table table-striped table-bordered table-condensed tool-result-table'})
print(divs)

1 个答案:

答案 0 :(得分:0)

尝试

from selenium import webdriver
from time import sleep 

obj = webdriver.Chrome(#path to chrome driver)
obj.get('https://mxtoolbox.com/SuperTool.aspx?action=mx%3abuildersinmysore.com&run=toolpage')
sleep(5)     
#IP Address
print(obj.find_element_by_class_name('table-column-IP_Address').text)
#Hostname
print(obj.find_element_by_class_name('table-column-Hostname').text)