Skip to content

Instantly share code, notes, and snippets.

View allatambov's full-sized avatar

Alla Tambovtseva allatambov

View GitHub Profile
import requests
from bs4 import BeautifulSoup
page = requests.get("http://nplus1.ru/")
soup = BeautifulSoup(page.text)
links_raw = soup.find_all("a")
links_all = []
for link in links_raw:
links_all.append(link["href"])
# !pip install selenium
from selenium import webdriver as wd
br = wd.Chrome("/Users/allat/Downloads/chromedriver")
br.get("http://www.biblio-globus.ru/")
search = br.find_element_by_id("search_string")
search = br.find_element_by_id("search_string")
search.send_keys("Python")
import requests
from bs4 import BeautifulSoup
page = requests.get("https://nplus1.ru/")
soup = BeautifulSoup(page.text)
raw_links = soup.find_all("a")
news = []
for link in raw_links:
@allatambov
allatambov / 03-02
Last active February 3, 2022 10:47
numbers = [1, 0, 3, -5, 9, -8, -10, -12, 3, 7, 8]
if numbers[0] > 0:
print("Yes")
else:
print("No")
if numbers[0] > 0:
print("Yes")
### installing and loading packages ###
install.packages("rvest")
library(rvest)
library(tidyverse)
### parsing HTML ###
# read HTML by link
# dataset
View(USJudgeRatings)
# Pearson correlation
cor.test(USJudgeRatings$FAMI, USJudgeRatings$DECI)
# Spearman correlation
get_news <- function(link1){
page1 <- read_html(link1)
page1 %>% html_nodes(".table")
tables <- page1 %>% html_nodes(xpath = "//p[@class='table']")
rubs <- tables[1] %>% html_nodes("a") %>% html_text()
time <- tables[2] %>% html_nodes("time")
date <- time %>% html_attr("content")
date_unix <- time %>% html_attr("data-unix")
time_human <- time %>% html_node("span") %>% html_text()
diffc <- tables[3] %>% html_node(".difficult-value") %>%
# choose color
scat <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length,
type = "scatter", mode = "markers",
marker = list(color = "blue"))
scat <- scat %>% layout(title = list(text = "<b>Iris Data</b>"),
updatemenus = list(list(x = -0.5,
y = 4,
buttons = list(
## PART 1: PROPORTIONS ##
### COUNT DATA ###
girls <- read.csv("https://allatambov.github.io/twimc/names-girls.csv")
boys <- read.csv("https://allatambov.github.io/twimc/names-boys.csv")
girls <- girls[girls$Month == "январь" & girls$Year == 2018, ]
table(girls$Name)
install.packages("tidyverse")
library(tidyverse)
anames <- read.csv("https://allatambov.github.io/twimc/names.csv", encoding = "UTF-8")
names18 <- anames %>% filter(Year == 2018 & Month == "январь")
names18_f <- names18 %>% filter(Sex == "female")
names18_m <- names18 %>% filter(Sex == "male")