Skip to content

Commit

Permalink
initial skeleton of the package
Browse files Browse the repository at this point in the history
  • Loading branch information
feddelegrand7 committed Dec 1, 2019
1 parent cb95fb3 commit 5db52f6
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
@@ -1,2 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
^LICENSE\.md$
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
.Rhistory
.RData
.Ruserdata
inst/doc
10 changes: 9 additions & 1 deletion DESCRIPTION
Expand Up @@ -6,8 +6,16 @@ Author: Mohamed El Fodil Ihaddaden
Maintainer: The package maintainer <ihaddaden.fodeil@gmail.com>
Description: The rvest package is powerful nevertheless it may challenging to use it, especially for new R users.
The ralger package facilitates its use by considering the most important elements of the web scraping procedure.
License: MIT
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
URL: https://github.com/feddelegrand7/ralger
BugReports: https://github.com/feddelegrand7/ralger/issues
Suggests:
testthat (>= 2.1.0),
knitr,
rmarkdown
VignetteBuilder: knitr
Imports:
magrittr,
rvest
2 changes: 2 additions & 0 deletions LICENSE
@@ -0,0 +1,2 @@
YEAR: 2019
COPYRIGHT HOLDER: Mohamed El Fodil Ihaddaden
21 changes: 21 additions & 0 deletions LICENSE.md
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2019 Mohamed El Fodil Ihaddaden

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
35 changes: 26 additions & 9 deletions R/hello.R
@@ -1,17 +1,34 @@
pacman::p_load(usethis, roxygen2, devtools, available, rvest, magrittr)

# Some useful keyboard shortcuts for package authoring:
#
# Install Package: 'Ctrl + Shift + B'
# Check Package: 'Ctrl + Shift + E'
# Test Package: 'Ctrl + Shift + T'

pacman::p_load(usethis, roxygen2, devtools, available)
# scraping one page

scrap_one <- function(link, node){

# Find a package name
data <- lapply(link,
function(url){
url %>% read_html() %>%
html_nodes(node) %>%
html_text()
})

return(unlist(data))
}

# scraping multiple pages

scrap_more <- function(link, node, from = 0, to = 20){

data <- lapply(paste0(link, from:to),
function(url){
url %>% read_html() %>%
html_nodes(node) %>%
html_text()
})

return(unlist(data))
}

available('ralger') # OK !


# sync with Github

54 changes: 54 additions & 0 deletions README.Rmd
@@ -0,0 +1,54 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# ralger

<!-- badges: start -->
<!-- badges: end -->

The goal of ralger is to ...

## Installation


You can install the development version from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("feddelegrand7/ralger")
```
## Example

This is a basic example which shows you how to solve a common problem:

```{r example}
library(ralger)
## basic example code
```

What is special about using `README.Rmd` instead of just `README.md`? You can include R chunks like so:

```{r cars}
summary(cars)
```

You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date.

You can also embed plots, for example:

```{r pressure, echo = FALSE}
plot(pressure)
```

In that case, don't forget to commit and push the resulting figure files, so they display on GitHub!
53 changes: 53 additions & 0 deletions README.md
@@ -0,0 +1,53 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# ralger

<!-- badges: start -->

<!-- badges: end -->

The goal of ralger is to …

## Installation

You can install the development version from
[GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("feddelegrand7/ralger")
```

## Example

This is a basic example which shows you how to solve a common problem:

``` r
library(ralger)
## basic example code
```

What is special about using `README.Rmd` instead of just `README.md`?
You can include R chunks like so:

``` r
summary(cars)
#> speed dist
#> Min. : 4.0 Min. : 2.00
#> 1st Qu.:12.0 1st Qu.: 26.00
#> Median :15.0 Median : 36.00
#> Mean :15.4 Mean : 42.98
#> 3rd Qu.:19.0 3rd Qu.: 56.00
#> Max. :25.0 Max. :120.00
```

You’ll still need to render `README.Rmd` regularly, to keep `README.md`
up-to-date.

You can also embed plots, for example:

<img src="man/figures/README-pressure-1.png" width="100%" />

In that case, don’t forget to commit and push the resulting figure
files, so they display on GitHub\!
Binary file added man/figures/README-pressure-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tests/testthat.R
@@ -0,0 +1,4 @@
library(testthat)
library(ralger)

test_check("ralger")
19 changes: 19 additions & 0 deletions tests/testthat/test-hello.R
@@ -0,0 +1,19 @@

# scrap_one test
firms_name1 <- scrap_one(
link = "http://elmouchir.caci.dz/search_results.php?keyword=&category=&location=Alger&submit=Trouver",
node = ".listing_default"
)

print(firms_name1)

# scrap_more test
firms_name2 <- scrap_more(
"http://elmouchir.caci.dz/search_results.php?keyword=&category=&location=Alger&submit=Trouver&page=",
".listing_default",
from = 0,
to = 20

)

print(firms_name2)
2 changes: 2 additions & 0 deletions vignettes/.gitignore
@@ -0,0 +1,2 @@
*.html
*.R
19 changes: 19 additions & 0 deletions vignettes/ralger.Rmd
@@ -0,0 +1,19 @@
---
title: "ralger"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{ralger}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r setup}
library(ralger)
```

0 comments on commit 5db52f6

Please sign in to comment.