J'ai un problème où l'extraction de ce lienpage de chargement PhantomJS Python incorrect
me apporte des données de ce lien au lieu qui est la page principale elle-même. http://www.bursamalaysia.com/market/listed-companies/company-announcements/#/?category=all
Une idée pourquoi cela se produit-il? J'utilise du sélénium PhantomJS et de la belle soupe pour m'assister là-dedans.
# The standard library modules
import os
import sys
import re
import sqlite3
import locale
# The wget module
import wget
import time
import calendar
from datetime import datetime
# The BeautifulSoup module
from bs4 import BeautifulSoup
# The selenium module
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
def getURLS(url):
driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true'])
driver.get(url) # load the web page
src = driver.page_source
#Get text and split it
soup = BeautifulSoup(src, 'html5lib')
print soup
link ='http://www.bursamalaysia.com/market/listed-companies/company-announcements/#/?category=FA&sub_category=FA1&alphabetical=All&company=5250'
getURLS(link)
Solution de Alex Lucaci
def getURLS(url):
driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true'])
driver.get(url) # load the web page
src = driver.page_source
category_select = Select(driver.find_element_by_xpath('//*[@id="bm_announcement_types"]'))
category_select.select_by_visible_text("Financial Results")
category_select2 = Select(driver.find_element_by_xpath('//*[@id="bm_sub_announcement_types"]'))
category_select2.select_by_visible_text("Financial Results")
category_select3 = Select(driver.find_element_by_xpath('//*[@id="bm_company_list"]'))
category_select3.select_by_visible_text("7-ELEVEN MALAYSIA HOLDINGS BERHAD (5250)")
driver.find_element_by_xpath('//*[@id="bm_company_announcements_search_form"]/input[1]').click()
src = driver.page_source
soup = BeautifulSoup(src, 'html5lib')
link="http://www.bursamalaysia.com/market/listed-companies/company-announcements/#/?category=all"
getURLS(link)
hey, désolé mate. Je l'ai testé et imprimé la soupe. il affiche toujours les données de la page principale au lieu des valeurs filtrées. Y at-il un moyen de le faire passer à travers c'est déroulant sélectionner des valeurs à la place? – Napmi
J'ai modifié mon message initial. Regarde. –
merci compagnon! abit de googling sur la façon de frapper soumettre et vos nouvelles connaissances sur moi pour find_element_by_xpath et cela fonctionne! Merci beaucoup! – Napmi