问题
I have a webpage which dynamically displays a text which I want to copy into a text file using watir-webdriver or any other additional gems. Is it possible?? If yes, how??
Thanks in advance..
回答1:
If you are talking about web-scraping try Nokogiri
回答2:
I will assume that you you have HMTL like this:
<div id="tehcodez">teh codez</div>
This would save text teh codez
to file tehcodez.txt
(not tested):
text = browser.div(:id => "tehcodez").text
File.open("tehcodez.txt", "w") {|file| file.write(text) }
来源:https://stackoverflow.com/questions/11325947/can-i-copy-a-text-on-a-webpage-and-paste-it-in-a-text-file