I feel dumb as it seems so easy. But I am stuck with this one:

I built a scraper which gets me the titles of jobs. 
Works great but it includes the h1 tags. E.g. it saves the title of a job as:

"<*h1>Marketing Manager<*/h1>"
I do not know why he does not just take the value within the h1 tag.

But secondly, I just tried to strip the tags away by stripping the first 4 and last 5 characters of the title (title(4..-5). Unfortunately no function like strip seems to work (the error tells me its some weird nokogiri class that cannot be stripped).

So here is my code, hopefully someone knows a smart solution for my problem:

```
company_career_urls.each do |url|
  puts "gets job url"
  # get the specific job url
  html_file = open(url).read
  html_doc = Nokogiri::HTML(html_file)
  i = 0
  Vacancy.where(:companyname => "Lillydoo").destroy_all
  html_doc.search('.job-list-button a').each do |element|
    i = i+1
    if i > 7
    else
      job_url = element.attribute('href').value
      puts job_url
      #get the job name and description
      html_file = open(job_url).read
      html_doc = Nokogiri::HTML(html_file)
      job_description = html_doc.search('.inner ul')
      job_title = html_doc.search('.job-detail-desc h1') #this line seems to be the problem
      # job_title = job_title_html[4..-6]
      puts job_title

      resource_type = "image"
      type = "upload"
      version = 1234567890
      public_id = "wv7l1o6xwimtfvx2oxdw"
      format = "jpg"
      signature = Cloudinary::Utils.api_sign_request({:public_id=>public_id,
      :version=>version}, Cloudinary.config.api_secret)
      photo = "#{resource_type}/#{type}/v#{version}/#{public_id}.#{format}##{signature}"
      vacancy = Vacancy.create(title: job_title, companyname: 'Lillydoo', jobdescription: job_description, photo: photo)
    end
  end

```
['https://Stackoverflow.com/questions/53561760', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10075876/']
This gives you a bunch of elements:

```
job_title = html_doc.search('.job-detail-desc h1')

```

This gives you the text of the first one:

```
job_title = html_doc.at('.job-detail-desc h1').text

```
For HTML, a rule of thumb is that documents have `html` and `body` tags, and fragments usually do not. Try to use the `DocumentFragment` class because the text is not a valid HTML or XML document.

```
html_doc = Nokogiri::HTML::DocumentFragment.parse(html_file)

```