123
@@ -0,0 +1,70 @@
|
||||
#include "funcHeader.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
srand(time(0));
|
||||
People *professions1 = malloc(sizeof(People) * COUN);
|
||||
People *professions2 = malloc(sizeof(People) * COUN);
|
||||
|
||||
if (professions1 == NULL || professions2 == NULL)
|
||||
{
|
||||
printf("Mesta net\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
st_rand(professions1, COUN);
|
||||
st_rand(professions2, COUN);
|
||||
|
||||
printf("Perviy massiv:\n");
|
||||
print_struc(professions1, COUN);
|
||||
printf("\nVtoroi massiv:\n");
|
||||
print_struc(professions2, COUN);
|
||||
|
||||
sort_sel(professions1, COUN);
|
||||
sort_sel(professions2, COUN);
|
||||
|
||||
printf("\nPerviy massiv posle sort:\n");
|
||||
print_struc(professions1, COUN);
|
||||
printf("\nVtoroi massiv posle sort:\n");
|
||||
print_struc(professions2, COUN);
|
||||
|
||||
People *ans = binSearch(professions1, COUN, 15);
|
||||
|
||||
if (ans == NULL)
|
||||
printf("\nPeoples net\n");
|
||||
else
|
||||
printf("\nLength: %2d; name: %s\n", ans->count, ans->name);
|
||||
|
||||
printf("\nElement in perviy massiv: ");
|
||||
pst(professions1, COUN, (int)(COUN * 0.7));
|
||||
printf("Element in vtoroi massiv: ");
|
||||
pst(professions2, COUN, (int)(COUN * 0.3));
|
||||
|
||||
printf("\nNumber of para : %d\n", find_para(professions1, COUN, professions2, COUN));
|
||||
|
||||
st_fprintf(professions1, COUN, "professions.txt", "w");
|
||||
st_fprintf(professions2, COUN, "professions.txt", "a");
|
||||
|
||||
int line_number = lines_numf("professions.txt");
|
||||
printf("\nNumber of lines in professions.txt is %d\n", line_number);
|
||||
|
||||
People *professions3 = malloc(sizeof(People) * line_number);
|
||||
|
||||
if (professions3 == NULL)
|
||||
{
|
||||
printf("Mesta net\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
st_fscanf(professions3, line_number, "professions.txt");
|
||||
sort_sel(professions3, line_number);
|
||||
|
||||
Sleep(50000);
|
||||
|
||||
printf("\nTTretiy massiv is:\n");
|
||||
print_struc(professions3, line_number);
|
||||
free(professions1);
|
||||
free(professions2);
|
||||
free(professions3);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#define COUN 4
|
||||
#define LEN 8
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
typedef struct People
|
||||
{
|
||||
int count;
|
||||
char name[LEN];
|
||||
} People;
|
||||
|
||||
void print_struc(People professions[], int n);
|
||||
void sort_sel(People professions[], int n);
|
||||
void st_rand(People professions[], int n);
|
||||
People *binSearch(People professions[], int n, int k);
|
||||
void pst(People professions[], int s, int n);
|
||||
int find_para(People t1[], int n1, People t2[], int n2);
|
||||
void st_fprintf(People professions[], int n, char path[], char access[]);
|
||||
int lines_numf(char path[]);
|
||||
void st_fscanf(People t[], int n, char path[]);
|
||||
void swap(People *t1, People *t2);
|
||||
@@ -0,0 +1,149 @@
|
||||
#include "funcHeader.h"
|
||||
|
||||
void print_struc(People professions[], int n)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
printf("count: %3d; name: %s\n", professions[i].count, professions[i].name);
|
||||
}
|
||||
|
||||
void sort_sel(People professions[], int n)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < n - 1; i++)
|
||||
{
|
||||
for (j = i + 1; j < n; j++)
|
||||
{
|
||||
if (professions[j].count < professions[i].count)
|
||||
swap(professions + i, professions + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void st_rand(People professions[], int n)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
professions[i].count = rand() % 3 + 1;
|
||||
for (j = 0; j < LEN - 1; j++)
|
||||
professions[i].name[j] = 'a' + rand() % 25;
|
||||
professions[i].name[j + 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
People *binSearch(People professions[], int n, int k)
|
||||
{
|
||||
People *ans = NULL;
|
||||
int right = 0, left = n - 1;
|
||||
|
||||
while (right <= left)
|
||||
{
|
||||
int mid = (left + right) / 2;
|
||||
|
||||
if (professions[mid].count == k)
|
||||
{
|
||||
ans = &professions[mid];
|
||||
break;
|
||||
}
|
||||
right = (professions[mid].count < k) ? mid + 1 : right;
|
||||
left = (professions[mid].count > k) ? mid - 1 : left;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
void pst(People professions[], int s, int n)
|
||||
{
|
||||
if (n >= s)
|
||||
{
|
||||
printf("Out of range\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
printf("count: %2d; name: %s\n", professions[n].count, professions[n].name);
|
||||
}
|
||||
|
||||
int find_para(People t1[], int n1, People t2[], int n2)
|
||||
{
|
||||
int ans = 0, i;
|
||||
for (i = 0; i < n1; i++)
|
||||
{
|
||||
People *tans = binSearch(t2, n2, t1[i].count);
|
||||
if (tans == NULL)
|
||||
continue;
|
||||
ans++;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
void st_fprintf(People professions[], int n, char path[], char access[])
|
||||
{
|
||||
int i;
|
||||
FILE *f = fopen(path, access);
|
||||
if (f == NULL)
|
||||
{
|
||||
printf("Could not open file %s\n", path);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
fprintf(f, "%d %s\n", professions[i].count, professions[i].name);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
int lines_numf(char path[])
|
||||
{
|
||||
int ans = 0;
|
||||
char c;
|
||||
FILE *f = fopen(path, "r");
|
||||
if (f == NULL)
|
||||
{
|
||||
printf("Faila %s net...\n", path);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
while ((c = fgetc(f)) != EOF)
|
||||
{
|
||||
if (c == '\n')
|
||||
ans++;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return ans;
|
||||
}
|
||||
|
||||
void st_fscanf(People t[], int n, char path[])
|
||||
{
|
||||
int i;
|
||||
FILE *f = fopen(path, "r");
|
||||
if (f == NULL)
|
||||
{
|
||||
printf("Faila %s net...\n", path);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
fscanf(f, "%d %s\n", &t[i].count, t[i].name);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void swap(People *t1, People *t2)
|
||||
{
|
||||
People *tmp = malloc(sizeof(People));
|
||||
|
||||
if (tmp == NULL)
|
||||
{
|
||||
printf("could not malloc\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memcpy(tmp, t1, sizeof(People));
|
||||
memcpy(t1, t2, sizeof(People));
|
||||
memcpy(t2, tmp, sizeof(People));
|
||||
free(tmp);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
1 pkaeoew
|
||||
1 ujqrkpqP
|
||||
2 nllvevc=
|
||||
2 wrqqkwf(
|
||||
1 krxtlgme
|
||||
1 srgyisre
|
||||
3 tiflqbd(
|
||||
3 opukfbci
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
/* function to solve the Tower of Hanoi puzzle */
|
||||
void tower_of_hanoi(int n, char from, char to, char aux)
|
||||
{
|
||||
/* base case - when there's only one disk present */
|
||||
if (n == 1)
|
||||
{
|
||||
printf("Move disk 1 from rod %c to rod %c\n", from, to);
|
||||
return;
|
||||
}
|
||||
/* move n-1 disks from the source to auxiliary rod */
|
||||
tower_of_hanoi(n - 1, from, aux, to);
|
||||
/* move the remaining one disk from the source to destination rod */
|
||||
printf("Move disk %d from rod %c to rod %c\n", n, from, to);
|
||||
/* move n-1 disks from the auxiliary to destination rod */
|
||||
tower_of_hanoi(n - 1, aux, to, from);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
/* ask user for the number of disks */
|
||||
printf("Enter the number of disks: ");
|
||||
scanf("%d", &n);
|
||||
/* call the tower_of_hanoi function to solve the puzzle */
|
||||
tower_of_hanoi(n, 'A', 'C', 'B');
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "header.h"
|
||||
|
||||
void pr(node *tmp){
|
||||
int i;
|
||||
if(tmp == NULL){printf("[%p]\n", tmp); return;}
|
||||
while(tmp){
|
||||
printf("[%14p]<-[%14p]->[%14p] ", tmp->prev, tmp, tmp->next);
|
||||
printf("data: [%4ld] s[" , tmp->data);
|
||||
for(i=0;i<COUN; i++) printf("%c", tmp->s[i]);
|
||||
printf("]\n");
|
||||
tmp = tmp->next;
|
||||
}
|
||||
printf("---------------------\n");
|
||||
}
|
||||
|
||||
node *add_head(node *head, int hh){
|
||||
node *tmp=NULL;
|
||||
int i;
|
||||
if((tmp=malloc(sizeof(node)))==NULL){
|
||||
perror("malloc: NULL");
|
||||
exit(2);
|
||||
}
|
||||
tmp->prev=NULL;
|
||||
tmp->data=hh;
|
||||
for(i=0;i<COUN;i++) tmp->s[i]=((char)(65+rand()%25));
|
||||
if(head==NULL) tmp->next=NULL;
|
||||
else{
|
||||
tmp->next=head;
|
||||
head->prev=tmp;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
node *add_tail(node *head, int hh){
|
||||
node *tmp=NULL;
|
||||
node *t = NULL;
|
||||
int i;
|
||||
if((tmp=malloc(sizeof(node)))==NULL){
|
||||
perror("malloc: NULL");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
tmp->data=hh;
|
||||
for(i=0;i<COUN;i++) tmp->s[i]=((char)(65+rand()%25));
|
||||
tmp->next=NULL;
|
||||
if(head==NULL) tmp->prev=NULL;
|
||||
else{
|
||||
t = head;
|
||||
while(t->next!=NULL) t = t->next;
|
||||
t->next=tmp;
|
||||
tmp->prev=head;
|
||||
}
|
||||
return head;
|
||||
}
|
||||
|
||||
node *del_head(node *head){
|
||||
node *tmp = head;
|
||||
if(head==NULL) return NULL;
|
||||
if(head -> next == NULL){
|
||||
free(head);
|
||||
return NULL;
|
||||
}
|
||||
head = head->next;
|
||||
head -> prev = NULL;
|
||||
free(tmp);
|
||||
return head;
|
||||
}
|
||||
|
||||
node *del_tail(node *list){
|
||||
node *tail = NULL;
|
||||
if(list==NULL) return NULL;
|
||||
if(list -> next == NULL){
|
||||
free(list);
|
||||
return NULL;
|
||||
}
|
||||
tail = list;
|
||||
while(tail->next->next) tail = tail->next;
|
||||
free(tail->next);
|
||||
tail -> next=NULL;
|
||||
return list;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#define COUN 40
|
||||
|
||||
typedef struct Node
|
||||
{
|
||||
long int data;
|
||||
struct Node *next;
|
||||
struct Node *prev;
|
||||
char s[COUN];
|
||||
} node;
|
||||
|
||||
void pr(node *tmp);
|
||||
node *add_head(node *head, int hh);
|
||||
node *add_tail(node *head, int hh);
|
||||
node *del_head(node *head);
|
||||
node *del_tail(node *list);
|
||||
// node *sort(node *head);
|
||||
// int lenghth(node *list);
|
||||
// void writefile(const char *path, node *head);
|
||||
// node *readfile(const char *path);
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "header.h"
|
||||
#include <windows.h>
|
||||
|
||||
int main(int args, char *argv[])
|
||||
{
|
||||
node *head = NULL;
|
||||
int r;
|
||||
srand(time(NULL));
|
||||
|
||||
while ((r = (rand() % 100)) < 90)
|
||||
head = add_head(head, r);
|
||||
pr(head);
|
||||
head = del_head(head);
|
||||
pr(head);
|
||||
|
||||
head = add_tail(head, 5);
|
||||
pr(head);
|
||||
|
||||
head = del_tail(head);
|
||||
pr(head);
|
||||
}
|
||||
// Домашка: сортировка списка и вычисление длины списка(по желанию запись в файл и чтение с файла)
|
||||
// Ханойские башни игра написать
|
||||
@@ -0,0 +1,50 @@
|
||||
#include <stdio.h>
|
||||
#define N 5
|
||||
void sort_Select(int x, int *arr){
|
||||
int ind, temp = 0;
|
||||
int i,j;
|
||||
for(i=0;i<(x-1);i++){
|
||||
ind = i;
|
||||
for(j=i+1;j<x;j++){
|
||||
if(arr[ind]>arr[j]){
|
||||
ind = j;
|
||||
}
|
||||
}
|
||||
temp = arr[i];
|
||||
arr[i] = arr[ind];
|
||||
arr[ind] = temp;
|
||||
}
|
||||
|
||||
}
|
||||
//meow
|
||||
void sort_insert(int l, int *arr){
|
||||
int i, j, x;
|
||||
for(i=0;i<l;i++){
|
||||
j = i-1;
|
||||
x = arr[i];
|
||||
while((arr[j]>x)&&(j>=0)){
|
||||
arr[j+1] = arr[j];
|
||||
j--;
|
||||
arr[j+1] = x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
int main(int argc, char** argv) {
|
||||
int l,i;
|
||||
//printf("Vvedite razmer massiva: ");
|
||||
//scanf("%d", l);
|
||||
int arr[N] = {4,5,2,3,1};
|
||||
int arra[N] = {3,5,2,4,1};
|
||||
sort_Select(N, arr);
|
||||
sort_insert(N, arra);
|
||||
for(i=0;i<N;i++){
|
||||
printf("%d", arr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
for(i=0;i<N;i++){
|
||||
printf("%d", arra[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
struct list {
|
||||
char name[20];
|
||||
int age;
|
||||
float salary;
|
||||
};
|
||||
|
||||
int main(){
|
||||
struct list *person;
|
||||
int i, n = 2;
|
||||
person = malloc(n*sizeof(struct list));
|
||||
|
||||
for(i = 0; i<n; i++){
|
||||
printf("Enter name %d: ", i+1);
|
||||
scanf("%s", &(person+i)->name);
|
||||
|
||||
printf("Enter age %d: ", i+1);
|
||||
scanf("%d", &(person+i)->age);
|
||||
|
||||
printf("Enter salary %d: ", i+1);
|
||||
scanf("%f", &(person+i)->salary);
|
||||
}
|
||||
|
||||
for(i=0; i<n; i++){
|
||||
printf("Name: %s\n Age: %d\n Salary: %.2f\n", (person+i)->name, (person+i)->age, (person+i)->salary);
|
||||
|
||||
}
|
||||
free(person);
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<time.h>
|
||||
|
||||
void swap(int a[], int c, int d, int n){
|
||||
int temp;
|
||||
if((c>=n) || (d>=n)) return;
|
||||
temp = a[c];
|
||||
a[c] = a[d];
|
||||
a[d] = temp;
|
||||
}
|
||||
|
||||
void pa(int a[], int n){
|
||||
int i;
|
||||
for(i=0;i<n;i++){
|
||||
printf("a[%d] = %2d ", i, a[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void init(int *a, int n){
|
||||
srand(time(NULL));
|
||||
while(n--){
|
||||
*(a++)=rand()%100;
|
||||
}
|
||||
}
|
||||
|
||||
int main2(int n){
|
||||
int a[n];
|
||||
|
||||
init(a,n);
|
||||
pa(a,n);
|
||||
swap(a,1,4,n);
|
||||
pa(a,n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(){
|
||||
int alenght;
|
||||
printf("input n = ");
|
||||
scanf("%d", &alenght);
|
||||
return main2(alenght);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<time.h>
|
||||
#include<error.h>
|
||||
struct st1{
|
||||
int i;
|
||||
char s[128];
|
||||
};
|
||||
/*
|
||||
void sort_Select(int x, struct st1 ){
|
||||
struct st1 temp;
|
||||
int i,j;
|
||||
for(i=0;i<(x-1);i++){
|
||||
ind = i;
|
||||
for(j=i+1;j<x;j++){
|
||||
if(arr[ind]>arr[j]){
|
||||
ind = j;
|
||||
}
|
||||
}
|
||||
temp = arr[i];
|
||||
arr[i] = arr[ind];
|
||||
arr[ind] = temp;
|
||||
}
|
||||
}
|
||||
*/
|
||||
void st_rand(struct st1 temp[], int n){
|
||||
int k;
|
||||
int j;
|
||||
|
||||
|
||||
for(k=0; k<n; k++){
|
||||
(temp+k)->i = rand()%100;
|
||||
for(j=0;j<127;j++){
|
||||
(temp+k)->s[j]=((char)(65+rand()%25));
|
||||
}
|
||||
(temp+k)->s[127]='\0';
|
||||
}
|
||||
}
|
||||
/*void swap(struct st1 temp[], int c, int d, int n){
|
||||
Дописать функцию!
|
||||
}
|
||||
*/
|
||||
void st_print(struct st1 temp[], int n){
|
||||
int k;
|
||||
for(k=0;k<n;k++){
|
||||
printf("%d->[%2d][%s]\n", k, temp[k].i, (temp+k)->s);
|
||||
}
|
||||
}
|
||||
int main(int argc, char *argv[]){
|
||||
int alenght;
|
||||
printf("input n = ");
|
||||
scanf("%d", &alenght);
|
||||
struct st1 *pq=NULL;
|
||||
srand(time(NULL));
|
||||
|
||||
if((pq=malloc(alenght*sizeof(struct st1))) == NULL){
|
||||
printf("malloc: NULL\n");
|
||||
exit(2);
|
||||
}
|
||||
st_rand(pq,alenght);
|
||||
st_print(pq,alenght);
|
||||
free(pq);
|
||||
pq = NULL;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "st_func.h"
|
||||
#define N 5
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
struct st1 q[N];
|
||||
|
||||
st_rand(q,N);
|
||||
st_print(q,N);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
struct st1{
|
||||
int i;
|
||||
char s[128];
|
||||
};
|
||||
|
||||
void st_rand(struct st1 temp[], int n);
|
||||
void st_print(struct st1 temp[], int n);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include "st_func.h"
|
||||
|
||||
void st_rand(struct st1 temp[], int n){
|
||||
int k;
|
||||
int j;
|
||||
|
||||
srand(time(NULL));
|
||||
for(k=0; k<n; k++){
|
||||
(temp+k)->i = rand()%100;
|
||||
for(j=0;j<127;j++){
|
||||
(temp+k)->s[j]=((char)(65+rand()%25));
|
||||
}
|
||||
(temp+k)->s[127]='\0';
|
||||
}
|
||||
}
|
||||
|
||||
void st_print(struct st1 temp[], int n){
|
||||
int k;
|
||||
for(k=0;k<n;k++){
|
||||
printf("%d->[%2d][%s]\n", k, temp[k].i, (temp+k)->s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
struct st1{
|
||||
int i;
|
||||
char s[128];
|
||||
};
|
||||
|
||||
void st_rand(struct st1 temp[], int n);
|
||||
void st_print(struct st1 temp[], int n);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import psycopg2
|
||||
import wget
|
||||
from bs4 import BeautifulSoup
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
# Парсер и загрузчик в БД//Антипенко Дмитрий
|
||||
connection = psycopg2.connect(host='localhost', dbname='PythonDB', user='postgres', password='Q1w2e3r4')
|
||||
|
||||
cursor = connection.cursor()
|
||||
|
||||
creat_qwery = """ create table Parser
|
||||
(id serial primary key, page_name varchar(100), price varchar(10), priceDis varchar(30), mark varchar(10), scr varchar(100))"""
|
||||
|
||||
cursor.execute(creat_qwery)
|
||||
connection.commit()
|
||||
|
||||
driver = Service('D:\\teach\Prog\chromedriver.exe')
|
||||
browser = webdriver.Chrome(service=driver)
|
||||
browser.get('https://amwine.ru/catalog/igristoe_vino_i_shampanskoe/igristoe_vino/')
|
||||
html_code = browser.page_source
|
||||
b_soup = BeautifulSoup(html_code, 'lxml')
|
||||
name = b_soup.find_all('a', class_="catalog-list-item__title js-product-detail-link")
|
||||
price = b_soup.find_all('span', class_="middle_price")
|
||||
priceDis = b_soup.find_all('span', class_="baseoldprice")
|
||||
mark = b_soup.find_all('span', class_="product-rating__rating")
|
||||
pictures = b_soup.find_all('div', class_="catalog-list-item__img-wrapper")
|
||||
|
||||
for i in range(15):
|
||||
url = 'https://amwine.ru'+pictures[i].find('a').find('img').attrs['data-src']
|
||||
filename = f"Programming\\23.03\img\{i}.jpg"
|
||||
print(filename)
|
||||
wget.download(url, filename)
|
||||
ins_qwery = f"""insert into public.Parser(page_name, price, priceDis, mark, scr) values ('{name[i].text}', '{price[i].text}', '{priceDis[i].text}', '{mark[i].text}', '{filename}')"""
|
||||
cursor.execute(ins_qwery)
|
||||
connection.commit()
|
||||
|
||||
|
||||
|
||||
|
||||
cursor.close()
|
||||
|
||||
connection.close()
|
||||
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 97 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 120 KiB |
|
After Width: | Height: | Size: 126 KiB |
@@ -0,0 +1,30 @@
|
||||
'''
|
||||
print("Введите размер массива: ")
|
||||
n = int(input())
|
||||
a = [int(input()) for i in range(n)]
|
||||
'''
|
||||
a = [4,3,2,5,1]
|
||||
b = a.copy()
|
||||
def sortSelect(arr):
|
||||
for i in range(len(arr)-1):
|
||||
ind = i
|
||||
for j in range(i+1, len(arr)):
|
||||
if(arr[ind]>arr[j]):
|
||||
ind = j
|
||||
arr[i], arr[ind] = arr[ind], arr[i]
|
||||
return arr
|
||||
|
||||
|
||||
def sortInsert(arr):
|
||||
for i in range(len(arr)):
|
||||
j = i-1
|
||||
x = arr[i]
|
||||
while((arr[j]>x)and(j>=0)):
|
||||
arr[j+1] = arr[j]
|
||||
j -= 1
|
||||
arr[j+1] = x
|
||||
return arr
|
||||
#meow
|
||||
|
||||
|
||||
print(sortSelect(a), sortInsert(b))
|
||||
@@ -0,0 +1,43 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
import psycopg2
|
||||
import wget
|
||||
|
||||
# connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
|
||||
# cursor = connection.cursor()
|
||||
|
||||
s = Service('D:\Games\data\chromedriver.exe')
|
||||
browser = webdriver.Chrome(service=s)
|
||||
browser.get('https://www.volkswagen.ru/polo/')
|
||||
html_text = browser.page_source
|
||||
soup = BeautifulSoup(html_text, 'lxml')
|
||||
|
||||
# creat_table = """ create table Cars_volks
|
||||
# (id serial primary key, car_name varchar(20),
|
||||
# price varchar(15), adress varchar(40),
|
||||
# scr varchar(100)) """
|
||||
#cursor.execute(creat_table)
|
||||
# connection.commit()
|
||||
|
||||
car_names = soup.find_all('div', class_='avn001-2_name')
|
||||
prices = soup.find_all('div', class_='avn001-2_price-container')
|
||||
adresses = soup.find_all('div', class_='avn001-2_dealer-link__text')
|
||||
pictures = soup.find_all('div', class_='avn001-2_image image__container')
|
||||
|
||||
#for car_name, adress, price in zip(car_names, adresses, prices):
|
||||
# print(f"Название машины:{car_name.text} | Адрес диллера: {adress.text} | Цена: {price.text} рублей")
|
||||
|
||||
for i in range(4):
|
||||
url = pictures[i].find('img').attrs['src']
|
||||
filename = f"Programming\\other\\img\\img{i}.jpg"
|
||||
print(filename)
|
||||
wget.download(url, filename)
|
||||
|
||||
# insert_qwery = f"""INSERT INTO public.Cars_volks(car_name, price, adress, scr)
|
||||
# VALUES ('{car_names[i].text}', '{prices[i].text}', '{adresses[i].text}', '{filename}')""";
|
||||
# cursor.execute(insert_qwery)
|
||||
# connection.commit()
|
||||
|
||||
# cursor.close()
|
||||
# connection.close()
|
||||
@@ -0,0 +1,33 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
import psycopg2
|
||||
import wget
|
||||
|
||||
browser = webdriver.Chrome(service=Service('C:\Desktop\exe\chromedriver.exe'))
|
||||
browser.get('https://flawery.ru/moscow/bouquets/event-yanvary25/')
|
||||
soup = BeautifulSoup(browser.page_source, "lxml")
|
||||
Name = soup.find_all(attrs={"class": "catalog_title"})
|
||||
Price = soup.find_all(attrs={"class": "catalog_price_now"})
|
||||
Delivery_Time = soup.find_all(attrs={"class": "catalog_express"})
|
||||
Delivery_Price = soup.find_all(attrs={"class": "catalog_delivery"})
|
||||
Image = soup.find_all('div', class_="catalog_item catalog_item_popup")
|
||||
|
||||
connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4')
|
||||
cursor = connection.cursor()
|
||||
create_q = '''CREATE TABLE Parse
|
||||
(ID serial primary key, Name varchar(100), Price varchar(9), Delivery_Time varchar(25), Delivery_Price varchar(20), src varchar(110))'''
|
||||
cursor.execute(create_q)
|
||||
connection.commit()
|
||||
|
||||
for j in range(10):
|
||||
url = 'https://flawery.ru'+Image[j].find('a').find('img').attrs['src']
|
||||
print(url)
|
||||
tempf = f'C:\\Users\\user\\Desktop\\FHWDB{j}.jpg'
|
||||
wget.download(url, tempf)
|
||||
insert_query = f'''INSERT into public.Parse(Name, Price, Delivery_Time, Delivery_Price, scr) values ('{Name[j].text}', '{Price[j].text}', '{Delivery_Time[j].text}', '{Delivery_Price[j].text}', '{tempf}') '''
|
||||
cursor.execute(insert_query)
|
||||
connection.commit()
|
||||
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,40 @@
|
||||
|
||||
#Вариант с пары
|
||||
'''
|
||||
from bs4 import BeautifulSoup
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
import time
|
||||
|
||||
S = Service('D:\teach\Prog\chromedriver.exe') #Открыли драйвер для хрома
|
||||
browser = webdriver.Chrome(service=S) #Инициировали в отдельную переменную
|
||||
browser.get('https://www.kinopoisk.ru/lists/movies/top250/')
|
||||
html_text = browser.page_source
|
||||
time.sleep(20)
|
||||
soup = BeautifulSoup(html_text, 'lxml')
|
||||
films = soup.find_all('div', class_='base-movie-main-info_mainInfo__ZL_u3')
|
||||
|
||||
print(soup)
|
||||
print(films)
|
||||
|
||||
for film in films:
|
||||
print(film.text)
|
||||
'''
|
||||
#Домашка
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
|
||||
driver = Service('D:\teach\Prog\chromedriver.exe')
|
||||
browser = webdriver.Chrome(service=driver)
|
||||
browser.get('https://hmbrussia.ru/regional-office/')
|
||||
html_code = browser.page_source
|
||||
b_soup = BeautifulSoup(html_code, 'lxml')
|
||||
name = b_soup.find_all('div', class_="ps-xl-3 ms-xl-3")
|
||||
|
||||
print(b_soup)
|
||||
print(name)
|
||||
|
||||
for i in name:
|
||||
print(i.text)
|
||||