[ Foro de Python ]
Estoy intentado extraer con python todos los links ocultos de una página que, al parecer, los construye dinámicamente desde javascript o algo así parece. Digo al parecer porque no conozco mucho de javascript. Se me ocurrió ejecutar código javascript con selenium para reconstruir los enlaces ocultos, pero no tuve suerte porque ejecuta la función script pero el enlace sigue permaneciendo oculto. También pensé en ejecutar el código javascript usando PyV8, pero tampoco funcionó. ¿alguien tiene idea de cómo hacerlo?.
Transcribo parte del código aquí:
from selenium import webdriver
import urllib2
from bs4 import BeautifulSoup
wd=webdriver.Firefox()
ydl_opts={}
wd.get('https://www.cultmoviez.info/playercult/playcult.php?tus=encGq7FhvGKuIYd3o%2BTrmdkjw%3D%3D&pic=59484369485561572b776a6f394a77587577576d6d587446395a4359705a4c63596b7273375742715458453dpenc&ucl=encvFBamkUzpjQM5zLcLyXjkg%3D%3D&pic=356e564278486b536271454f36437945715162763038657045466735636931475478777759697479764c70663648365776634c614f5a6978435836577a46575473745655336f516e47323733687a656c714d5156554379464d497934444c763069594a525631644c3364675374364470547653434d74565250644334363137726758793869486644584a4f6e755248315a32397337567477746c7a626b754c4a64347a46575266534947413331535271766d31513334435a4e6a6b66302f6336565476464832336a365957424d3257512b426a6871773d3dpenc&up1=m869c1qv5yvu&up=m869c1qv5yvu&dp=n3a6pgout&mega=!vlh2xBZL!_TQC3UWUQRP1bDPtBrAXH9nkxd2KmUs2LtFbQdxI4eI&id=tt0130709&v=2.0.31')
htmlcode=wd.execute_script("reproducir(1)")
print htmlcode
import execjs
import urllib2
import PyV8
from bs4 import BeautifulSoup
resp=urllib2.urlopen('https://www.cultmoviez.info/playercult/playcult.php?tus=encGq7FhvGKuIYd3o%2BTrmdkjw%3D%3D&pic=59484369485561572b776a6f394a77587577576d6d587446395a4359705a4c63596b7273375742715458453dpenc&ucl=encvFBamkUzpjQM5zLcLyXjkg%3D%3D&pic=356e564278486b536271454f36437945715162763038657045466735636931475478777759697479764c70663648365776634c614f5a6978435836577a46575473745655336f516e47323733687a656c714d5156554379464d497934444c763069594a525631644c3364675374364470547653434d74565250644334363137726758793869486644584a4f6e755248315a32397337567477746c7a626b754c4a64347a46575266534947413331535271766d31513334435a4e6a6b66302f6336565476464832336a365957424d3257512b426a6871773d3dpenc&up1=m869c1qv5yvu&up=m869c1qv5yvu&dp=n3a6pgout&mega=!vlh2xBZL!_TQC3UWUQRP1bDPtBrAXH9nkxd2KmUs2LtFbQdxI4eI&id=tt0130709&v=2.0.31')
data=resp.read()
ctx=PyV8.JSContext()
ctx.eval(data)
print ctx.eval("reproducir2",1)
(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)