Advertisement
stuppid_bot

Грабим ссылки на гифки gifyo.com

Feb 9th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var nodeList = document.getElementsByClassName('gif-link');
  2. var urls = [];
  3. for (var i = 0; i < nodeList.length; ++i) {
  4.     var req = new XMLHttpRequest;
  5.     req.open('GET', nodeList[i].href, false);
  6.     req.onload = function () {
  7.         urls.push(req.response.match(/<div class="gif type2" >\s+<img src="([^"]+)/)[1]);
  8.     }
  9.     req.send();
  10. }
  11. var link = document.createElement('a');
  12. link.setAttribute('download', 'links.txt');
  13. link.href = 'data:plain/text,' + encodeURIComponent(urls.join('\n'));
  14. link.setAttribute('style', 'display: none');
  15. link.onclick = function () {
  16.     document.body.removeChild(link);
  17. };
  18. document.body.appendChild(link);
  19. link.click();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement