I want to extract a part of the web page source. Now I can extract all html code and output proper code. However, I want to extract only a part of code.
The following is their html code, I want to crawl. I want to crawl only red range:
And then, the following is my python code:
from datetime import date,datetime
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import numpy as np
import xlrd
import csv
import codecs
import time
import os
driver_blank=webdriver.Chrome('./chromedriver')
driver_blank.get('https://forumd.hkgolden.com/view.aspx?type=CA&message=7223327')
time.sleep(1)
try_value = 1
while(try_value):
try:
driver_blank.find_element_by_xpath('/html/body/form/div[5]/div/div/div[2]/div[1]/div[5]/table[2]')
print('OK')
try_value=0
except NoSuchElementException as e:
print('Refreash now')
driver_blank.refresh()
time.sleep(10)
html_code = driver_blank.page_source
print(html_code)
Can I use full Xpath to locate this range?
