Created
May 18, 2019 23:30
-
-
Save Maxim-Mazurok/700d85d8dd7ea02902a0e01930e20347 to your computer and use it in GitHub Desktop.
Script that parses first 10 pages of your followings and prints curl-commands to unfollow them on codecanyon.net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// script that parses first 10 pages of your followings and prints curl-commands to unfollow them on codecanyon.net | |
const fetch = require("node-fetch"); | |
const regex = /<a class="avatar" title="(.+?)"/gm; | |
//TODO: change pages count if needed | |
for (let page = 1; page <= 10; page++) { | |
fetch(`https://codecanyon.net/user/maxim_mazurok/following?page=${page}`) | |
.then(res => res.text()) | |
.then(result => { | |
let m; | |
while ((m = regex.exec(result)) !== null) { | |
// This is necessary to avoid infinite loops with zero-width matches | |
if (m.index === regex.lastIndex) { | |
regex.lastIndex++; | |
} | |
// The result can be accessed through the `m`-variable. | |
m.forEach((match, groupIndex) => { | |
if (groupIndex === 1) { | |
//TODO: use your own curl string (with cookies, session, etc.) | |
console.log(`curl \'https://codecanyon.net/user/${match}/unfollow\' -H \'cookie: xxxx\' -H \'origin: https://codecanyon.net\' -H \'accept-encoding: gzip, deflate, br\' -H \'x-csrf-token: xxxx\' -H \'accept-language: en-GB,en-US;q=0.9,en;q=0.8,ru;q=0.7,uk;q=0.6\' -H \'x-requested-with: XMLHttpRequest\' -H \'pragma: no-cache\' -H \'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36\' -H \'content-type: application/x-www-form-urlencoded; charset=UTF-8\' -H \'accept: */*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript\' -H \'cache-control: no-cache\' -H \'authority: codecanyon.net\' -H \'referer: https://codecanyon.net/user/${match}\' --data \'utf8=%E2%9C%93\' --compressed`) | |
} | |
}); | |
} | |
}) | |
.catch(error => console.error(error)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment