Last active
October 8, 2019 09:13
-
-
Save carlosernestolopez/4e564e918becd7c796192de54ca3e0a9 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Web; | |
namespace todoBusco | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
object locker = new object(); | |
string numero_galeano = "50585524261"; | |
List<string> urls = new List<string>() { }; | |
DirectoryInfo dir = new DirectoryInfo("./urls"); | |
FileInfo[] files = dir.GetFiles("*.txt"); | |
foreach(FileInfo file in files) | |
{ | |
string[] _urls = File.ReadAllLines(file.FullName); | |
foreach (string url in _urls) { | |
if( url != "" ) | |
urls.Add(url); | |
} | |
} | |
string[] shuffleMe = urls.ToArray(); | |
var rng = new Random(); | |
rng.Shuffle(shuffleMe); | |
List<string> urls_shu = shuffleMe.ToList<string>(); | |
int total = urls_shu.Count(); | |
int count = 0; | |
// ENVIAR PETICION | |
Parallel.ForEach(urls_shu, url => { | |
using (WebClient wc = new WebClient()) | |
{ | |
lock (locker) | |
{ | |
count++; | |
} | |
string id_publicacion = url.Split('-').Last(); | |
wc.Headers.Add("Cookie", File.ReadAllText("cookie.txt")); | |
wc.Headers.Add("x-requested-with", "XMLHttpRequest"); | |
wc.Headers.Add("content-type", "application/x-www-form-urlencoded"); | |
wc.Headers.Add("Referer", url); | |
string request = "txtIdAviso=" + id_publicacion + "&txtMessage=Hola.+Estoy+interesado+que+me+llamen+al+siguiente+n%C3%BAmero%3A+" + numero_galeano + "&txtUrlAviso=" + HttpUtility.UrlEncode(url) + "&txtNumber=" + numero_galeano; | |
try | |
{ | |
string result = wc.UploadString("https://todobusco.com/ficha-aviso/callme", request); | |
Console.WriteLine("Solicitud hacia " + id_publicacion + " enviada " + count + " / " + total + " | Resultado: " + result); | |
} | |
catch (Exception ex) { | |
try { | |
string result = wc.UploadString("https://todobusco.com/ficha-aviso/callme", request); | |
Console.WriteLine("Solicitud hacia " + id_publicacion + " enviada " + count + " / " + total + " | Resultado: " + result); | |
} | |
catch (Exception ex2) { | |
Console.WriteLine("ERROR consultando " + url); | |
} | |
} | |
} | |
}); | |
} | |
} | |
static class RandomExtensions | |
{ | |
public static void Shuffle<T>(this Random rng, T[] array) | |
{ | |
int n = array.Length; | |
while (n > 1) | |
{ | |
int k = rng.Next(n--); | |
T temp = array[n]; | |
array[n] = array[k]; | |
array[k] = temp; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment