栈
This commit is contained in:
parent
acd4b7ef36
commit
a9fa4915e3
69
c/code/data_struct/main.c
Normal file
69
c/code/data_struct/main.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
struct link_list_struct
|
||||||
|
{
|
||||||
|
struct link_list_struct * back_node;
|
||||||
|
int current_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void add_node ( struct link_list_struct **current_node , int content )
|
||||||
|
{
|
||||||
|
struct link_list_struct *new_node = malloc(sizeof(struct link_list_struct));
|
||||||
|
new_node->back_node = *current_node;
|
||||||
|
new_node->current_data = content;
|
||||||
|
*current_node = new_node;
|
||||||
|
};
|
||||||
|
|
||||||
|
void delete_node(struct link_list_struct **current_node){
|
||||||
|
if(*current_node == NULL){
|
||||||
|
printf ("当前没有结点\n");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
struct link_list_struct *tmp_node;
|
||||||
|
tmp_node = *current_node;
|
||||||
|
*current_node = (*current_node)->back_node;
|
||||||
|
free (tmp_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void view_node(struct link_list_struct *current_node){
|
||||||
|
if(current_node == NULL){
|
||||||
|
printf ("当前没有结点\n");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
printf ("%d\n",current_node->current_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
enum {add=1,delete,view};
|
||||||
|
struct link_list_struct *current_node=NULL;
|
||||||
|
|
||||||
|
while( true){
|
||||||
|
printf ("1.增加\n");
|
||||||
|
printf ("2.删除\n");
|
||||||
|
printf ("3.查看\n");
|
||||||
|
printf ("请输入:");
|
||||||
|
int pick;
|
||||||
|
scanf_s ("%d",&pick);
|
||||||
|
if(pick==add)
|
||||||
|
{
|
||||||
|
int content;
|
||||||
|
printf ("请输入要添加的数值:");
|
||||||
|
scanf_s ("%d",&content);
|
||||||
|
add_node (¤t_node,content);
|
||||||
|
}
|
||||||
|
else if(pick==delete)
|
||||||
|
{
|
||||||
|
delete_node(¤t_node);
|
||||||
|
}
|
||||||
|
else if(pick==view)
|
||||||
|
{
|
||||||
|
view_node (current_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
69
c/code/data_struct/stack.c
Normal file
69
c/code/data_struct/stack.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
struct link_list_struct
|
||||||
|
{
|
||||||
|
struct link_list_struct * back_node;
|
||||||
|
int current_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void add_node ( struct link_list_struct **current_node , int content )
|
||||||
|
{
|
||||||
|
struct link_list_struct *new_node = malloc(sizeof(struct link_list_struct));
|
||||||
|
new_node->back_node = *current_node;
|
||||||
|
new_node->current_data = content;
|
||||||
|
*current_node = new_node;
|
||||||
|
};
|
||||||
|
|
||||||
|
void delete_node(struct link_list_struct **current_node){
|
||||||
|
if(*current_node == NULL){
|
||||||
|
printf ("当前没有结点\n");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
struct link_list_struct *tmp_node;
|
||||||
|
tmp_node = *current_node;
|
||||||
|
*current_node = (*current_node)->back_node;
|
||||||
|
free (tmp_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void view_node(struct link_list_struct *current_node){
|
||||||
|
if(current_node == NULL){
|
||||||
|
printf ("当前没有结点\n");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
printf ("%d\n",current_node->current_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
enum {add=1,delete,view};
|
||||||
|
struct link_list_struct *current_node=NULL;
|
||||||
|
|
||||||
|
while( true){
|
||||||
|
printf ("1.增加\n");
|
||||||
|
printf ("2.删除\n");
|
||||||
|
printf ("3.查看\n");
|
||||||
|
printf ("请输入:");
|
||||||
|
int pick;
|
||||||
|
scanf_s ("%d",&pick);
|
||||||
|
if(pick==add)
|
||||||
|
{
|
||||||
|
int content;
|
||||||
|
printf ("请输入要添加的数值:");
|
||||||
|
scanf_s ("%d",&content);
|
||||||
|
add_node (¤t_node,content);
|
||||||
|
}
|
||||||
|
else if(pick==delete)
|
||||||
|
{
|
||||||
|
delete_node(¤t_node);
|
||||||
|
}
|
||||||
|
else if(pick==view)
|
||||||
|
{
|
||||||
|
view_node (current_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,77 +0,0 @@
|
|||||||
from selenium import webdriver # 驱动
|
|
||||||
from selenium.webdriver.common.by import By # 解析方式
|
|
||||||
from selenium.webdriver import Keys # 模拟按键
|
|
||||||
from selenium.webdriver.common.action_chains import ActionChains
|
|
||||||
import time
|
|
||||||
# 开启无头浏览器
|
|
||||||
from selenium.webdriver.chrome.options import Options
|
|
||||||
|
|
||||||
|
|
||||||
class google_map_script:
|
|
||||||
def __init__(self, url, head, frequency):
|
|
||||||
self.url = url
|
|
||||||
self.head = head
|
|
||||||
self.frequency = frequency
|
|
||||||
|
|
||||||
def start(self):
|
|
||||||
if self.head:
|
|
||||||
options = Options()
|
|
||||||
options.add_argument("--headless")
|
|
||||||
options.add_argument("--disable-gpu")
|
|
||||||
driver = webdriver.Chrome(options=options) # 创建浏览器对象
|
|
||||||
else:
|
|
||||||
driver = webdriver.Chrome()
|
|
||||||
|
|
||||||
def work(self, driver):
|
|
||||||
driver.get(self.url)
|
|
||||||
time.sleep(3)
|
|
||||||
scrollable_element = driver.find_element(By.XPATH,
|
|
||||||
'//*[@id="QA0Szd"]/div/div/div[1]/div[2]/div/div[1]/div/div/div[1]/div[1]')
|
|
||||||
|
|
||||||
for i in range(10):
|
|
||||||
scrollable_element.send_keys(Keys.PAGE_DOWN)
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
divs = driver.find_elements(By.XPATH,
|
|
||||||
'//div/div/div[1]/div[2]/div/div[1]/div/div/div[1]/div[1]/div[not(@class)]')
|
|
||||||
for div in divs:
|
|
||||||
info_dict = {"店名": "", "地址": "", "电话": "", "网站": "", "Plus Code": "", "星期一": "", "星期二": "",
|
|
||||||
"星期三": "",
|
|
||||||
"星期四": "", "星期五": "", "星期六": "", "星期日": ""}
|
|
||||||
info_content = []
|
|
||||||
div.click()
|
|
||||||
time.sleep(1)
|
|
||||||
info_path_1 = "//div/div/div[1]/div[3]/div/div[1]/div/div/div[2]/div[7]"
|
|
||||||
info_path_2 = "//div/div/div[1]/div[3]/div/div[1]/div/div/div[2]/div[8]"
|
|
||||||
title = driver.find_element(By.XPATH,
|
|
||||||
'//div/div/div[1]/div[3]/div/div[1]/div/div/div[2]/div[2]/div/div[1]/div[1]/h1').text
|
|
||||||
info_dict["店名"] = title
|
|
||||||
info_divs = driver.find_element(By.XPATH, info_path_1)
|
|
||||||
|
|
||||||
role_test = info_divs.get_attribute("role")
|
|
||||||
if role_test == "presentation":
|
|
||||||
info_divs = driver.find_element(By.XPATH, info_path_2)
|
|
||||||
|
|
||||||
a_s = info_divs.find_elements(By.XPATH, './/a')
|
|
||||||
button_s = info_divs.find_elements(By.XPATH, './/button')
|
|
||||||
|
|
||||||
for a in a_s:
|
|
||||||
a_info = a.get_attribute("aria-label")
|
|
||||||
if a is not None:
|
|
||||||
info_content.append(a_info)
|
|
||||||
|
|
||||||
for button in button_s:
|
|
||||||
button_info = button.get_attribute("aria-label")
|
|
||||||
if button_info is not None:
|
|
||||||
info_content.append(button_info)
|
|
||||||
|
|
||||||
for info in info_content:
|
|
||||||
tmp_content = info.split(":", 1)
|
|
||||||
if tmp_content[0] in ["地址", "电话", "Plus Code", "网站"]:
|
|
||||||
info_dict[tmp_content[0]] = tmp_content[1].strip()
|
|
||||||
tmp_content = info.split(",", 1)
|
|
||||||
if tmp_content[0] in ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]:
|
|
||||||
tmp_time = tmp_content[1].split("、", -1)
|
|
||||||
info_dict[tmp_content[0]] = tmp_time[0].strip()
|
|
||||||
|
|
||||||
print(info_dict)
|
|
Loading…
Reference in New Issue
Block a user