#!/bin/bash
set -e
FOLDER="photos"
mkdir -p $FOLDER
function download () {
local url=$1
local name=$2
filename=$(basename "$url")
extension="${filename##*.}"
wget -O"${FOLDER}/${name}.${extension}" "${url}"
}
while read line
do
name=$(echo $line | awk -F ";" ' {print $1} ' | sed -e "s/\ /_/g")
url=$(echo $line | awk -F ";" ' {print $2} ')
download "${url}" "${name}"
done < $1
$ ./script.sh table.csv
Ярков Алексей Николаевич;https://avatars2.githubusercontent.com/u/6022892?v=4&s=460
Иванов Иван Иванович;https://avatars2.githubusercontent.com/u/23380632?v=4&s=460
char* generate_password(char *symbols, int length)
{
srandom(time(NULL));
int counter = 0;
char randChar;
char *result = malloc(length + 1); // FIX
if(length < 1) {
printf("Type in a password Length \n");
scanf("%d", &length);
}
while(counter < length)
{
randChar = symbols[random () % strlen(symbols)];
result[counter] = randChar;
counter++;
}
return result;
}
__get_date() {
local date=$(date --date="-$1 day" +%d.%m.%Y)
echo ${date}
}
__get_url() {
local date="$1"
echo "http://webanetlabs.net/freeproxylist/proxylist_at_${date}.txt"
}
__get_status() {
local offset="$1"
local date=$(__get_date ${offset})
local __url=$(__get_url ${date})
local status=$(wget --spider -S ${__url} 2>&1 | grep "HTTP/" | awk '{print $2}')
echo "${status}"
}
get_proxy_list() {
local savefile=~/.PROXY_LIST
local counter=0
while [ $(__get_status ${counter}) != "200" ]; do
counter=$(($counter + 1))
done
local date=$(__get_date ${counter})
local url=$(__get_url ${date})
wget --output-document=${savefile} ${url} > /dev/null 2>&1
cat ${savefile}
}