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/']
The issue you're having is that `job_title` is not a simple string; it's a set of node object(s) that match the search. When you print it with `puts`, Ruby is calling `#to_s` on the node set and outputting the "HTML source" of all the nodes.

What you need to do is to isolate the node you want an then extract its text content using `#content` (or `#text`). Here's an example:

```
require 'nokogiri'

CONTENT = <<'EOT'
<html>
  <body>
    <h1>Test Heading</h1>
  </body>
</html>
EOT

html_doc = Nokogiri::HTML(CONTENT)

# this returns a set of all matching nodes
nodes = html_doc.css('h1')
puts nodes.class   # --> "Nokogiri::XML::NodeSet"
puts nodes         # --> "<h1>Test Heading<h1>"

# if you know you will only have one, use at_css
node = html_doc.at_css('h1')
puts node.class    # --> "Nokogiri::XML::Element"
puts node          # --> "<h1>Test Heading</h1>"

# to get just the text content inside the node
puts node.content  # --> "Test Heading"

```

See <https://www.nokogiri.org/tutorials/searching_a_xml_html_document.html>
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)

```