qdyxmas's Room

Done is better than perfect...

selenium 下调用jquery

browser = webdriver.Firefox() # Get local session of firefox

with open('jquery.min.js', 'r') as jquery_js: #read the jquery from a file
    jquery = jquery_js.read()
    browser.execute_script(jquery)  #active the jquery lib

#now you can write some jquery code then execute_script them
js = """
    var str = "div#myPager table a:[href=\\"javascript:__doPostBack('myPager','%s')\\"]"
    var $next_anchor = $(str);
    if ($next_anchor.length) {
        return $next_anchor.get(0).click(); //do click and redirect
    } else {
        return false;
    }""" % str(25) 

success = browser.execute_script(js)
if success == False:


1 评论

  1. CharlesVex

    “I haven’t seen you in these parts,” the barkeep said, sidling over and above to where I sat. “Name’s Bao.” He stated it exuberantly, as if word of his exploits were shared by settlers hither assorted a firing in Aeternum. He waved to a unimpassioned hogshead hard by us, and I returned his gesture with a nod. He filled a eyeglasses and slid it to me across the stained red wood of the bar prior to continuing. “As a betting houseman, I’d be delighted to wager a honourable portion of silver you’re in Ebonscale Reach for the purpose more than the swig and sights,” he said, eyes glancing from the sword sheathed on my in to the salaam slung across my back. https://maps.google.bg/url?q=https://renewworld.ru/budet-li-russkiy-yazyk-v-new-world/