Skip to content

Instantly share code, notes, and snippets.

View cheikhshift's full-sized avatar

Cheikh Seck cheikhshift

View GitHub Profile
function setValues(){
let form = JSON.parse(window.localStorage["form_of_bot"])
let keys = Object.keys(form)
for(let k of keys){
$(`input[name="${k}"]`).val(form[k])
}
setTimeout(() => {
$(".template-btn-submit").click(() =>{
scrapeInput()
})
}, 3000)
function scrapeInput(){
let working = false
// Since ads are loaded via
// ajax, i'm giving it 7 seconds
// to load and render.
setTimeout(() => {
// Check if on remote job page.
// only then, run query.
// Since ads are loaded via
// ajax, i'm giving it 7 seconds
// to load and render.
setTimeout(() => {
let working = false
// Check if on remote job page.
// only then, run query.
file := []byte{}
for _, part := range parts {
file = append(file, part...)
}
// Set permissions accordingly, 0700 may not
// be the best choice
err = ioutil.WriteFile("./data.zip", file, 0700)
for i := 0; i < workers; i++ {
go download(i, size, results)
}
counter := 0
for part := range results {
counter++
parts[part.Index] = part.Data
func download(index, size int, c chan Part) {
client := &http.Client{}
// calculate offset by multiplying
// index with size
start := index * size
// Write data range in correct format
// I'm reducing one from the end size to account for
func main() {
var size int
results := make(chan Part, workers)
parts := [workers][]byte{}
client := &http.Client{}
req, err := http.NewRequest("HEAD", url, nil)
type Part struct {
Data []byte
Index int
}
const (
// Sample download file provided by Vodafone
// to test internet
url = "http://212.183.159.230/5MB.zip"
// Number of Goroutines to spawn for download.
workers = 5
)